mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 13:56:15 -08:00
update docs
This commit is contained in:
1 parent
a0bc4d3a39
commit
1388df955f
16 files changed
+11133
-59
No files matched your search
+62
-42
@@ -465,7 +465,7 @@
|
||||
function validElement(paths, value, type) {
|
||||
if (type === 'string') {
|
||||
if (value.trim() === '') {
|
||||
throw new ArtPlayerError("".concat(paths.join('.'), " can not be empty'"));
|
||||
throw new ArtPlayerError("".concat(paths.join('.'), " can not be empty"));
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@@ -478,6 +478,18 @@
|
||||
throw new ArtPlayerError("".concat(paths.join('.'), " require 'string' or 'Element' type, but got '").concat(type, "'"));
|
||||
}
|
||||
|
||||
function validStringEmpty(paths, value, type) {
|
||||
if (type !== 'string') {
|
||||
throw new ArtPlayerError("".concat(paths.join('.'), " required 'string' type."));
|
||||
}
|
||||
|
||||
if (value.trim() === '') {
|
||||
throw new ArtPlayerError("".concat(paths.join('.'), " can not be empty"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var scheme = {
|
||||
container: {
|
||||
validator: validElement,
|
||||
@@ -485,7 +497,8 @@
|
||||
},
|
||||
url: {
|
||||
type: 'string',
|
||||
required: true
|
||||
required: true,
|
||||
validator: validStringEmpty
|
||||
},
|
||||
title: 'string',
|
||||
volume: 'number',
|
||||
@@ -676,7 +689,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
var _tinyEmitter_2_0_2_tinyEmitter = E;
|
||||
var tinyEmitter = E;
|
||||
|
||||
var Template = function Template(art) {
|
||||
classCallCheck(this, Template);
|
||||
@@ -822,9 +835,19 @@
|
||||
Object.keys(option.moreVideoAttr).forEach(function (key) {
|
||||
$video[key] = option.moreVideoAttr[key];
|
||||
});
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
$video.poster = option.poster;
|
||||
$video.autoplay = option.autoplay;
|
||||
|
||||
if (option.volume) {
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
}
|
||||
|
||||
if (option.poster) {
|
||||
$video.poster = option.poster;
|
||||
}
|
||||
|
||||
if (option.autoplay) {
|
||||
$video.autoplay = option.autoplay;
|
||||
}
|
||||
|
||||
sleep().then(function () {
|
||||
art.emit('beforeMountUrl', option.url);
|
||||
$video.src = player.mountUrl(option.url);
|
||||
@@ -3701,6 +3724,7 @@
|
||||
|
||||
classCallCheck(this, Controls);
|
||||
|
||||
id = 0;
|
||||
this.art = art;
|
||||
this.art.on('firstCanplay', function () {
|
||||
_this.init();
|
||||
@@ -3790,16 +3814,17 @@
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(control) {
|
||||
value: function add(control, callback) {
|
||||
var option = control.option;
|
||||
|
||||
if (option && !option.disable) {
|
||||
id++;
|
||||
var name = option.name || control.constructor.name.toLowerCase() || "control".concat(id);
|
||||
var name = option.name || "control".concat(id);
|
||||
var $control = document.createElement('div');
|
||||
$control.setAttribute('class', "art-control art-control-".concat(name));
|
||||
this.mount(option.position, $control, option.index || id);
|
||||
control.apply && control.apply(this.art, $control);
|
||||
callback && callback($control);
|
||||
this[name] = control;
|
||||
}
|
||||
}
|
||||
@@ -3914,7 +3939,7 @@
|
||||
disable: false,
|
||||
name: 'version',
|
||||
index: 40,
|
||||
html: '<a href="https://github.com/zhw2590582/artplayer" target="_blank">ArtPlayer 1.0.0</a>'
|
||||
html: '<a href="https://github.com/zhw2590582/artplayer" target="_blank">ArtPlayer 1.0.2</a>'
|
||||
};
|
||||
|
||||
function close(art) {
|
||||
@@ -3937,6 +3962,7 @@
|
||||
function Contextmenu(art) {
|
||||
classCallCheck(this, Contextmenu);
|
||||
|
||||
id$1 = 0;
|
||||
this.art = art;
|
||||
this.init();
|
||||
}
|
||||
@@ -3969,7 +3995,7 @@
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(item) {
|
||||
value: function add(item, callback) {
|
||||
var _this2 = this;
|
||||
|
||||
if (!item.disable) {
|
||||
@@ -3977,9 +4003,10 @@
|
||||
refs = _this$art2.refs,
|
||||
proxy = _this$art2.events.proxy;
|
||||
id$1++;
|
||||
var name = item.name || "menu".concat(id$1);
|
||||
var menu = typeof item === 'function' ? item(this.art) : item;
|
||||
var $menu = document.createElement('div');
|
||||
$menu.setAttribute('class', "art-menu art-menu-".concat(menu.name || id$1));
|
||||
$menu.setAttribute('class', "art-menu art-menu-".concat(name || id$1));
|
||||
append($menu, menu.html);
|
||||
setStyles($menu, menu.style || {});
|
||||
|
||||
@@ -3992,7 +4019,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
this["$".concat(menu.name || id$1)] = $menu;
|
||||
callback && callback($menu);
|
||||
this[name] = $menu;
|
||||
insertByIndex(refs.$contextmenu, $menu, menu.index || id$1);
|
||||
}
|
||||
}
|
||||
@@ -4096,7 +4124,7 @@
|
||||
key: "creatInfo",
|
||||
value: function creatInfo() {
|
||||
var infoHtml = [];
|
||||
infoHtml.push("\n <div class=\"art-info-item \">\n <div class=\"art-info-title\">Player version:</div>\n <div class=\"art-info-content\">1.0.0</div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item \">\n <div class=\"art-info-title\">Player version:</div>\n <div class=\"art-info-content\">1.0.2</div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video url:</div>\n <div class=\"art-info-content\" data-video=\"currentSrc\"></div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video type:</div>\n <div class=\"art-info-content\" data-head=\"Content-Type\"></div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video size:</div>\n <div class=\"art-info-content\" data-head=\"Content-length\"></div>\n </div>\n ");
|
||||
@@ -4492,6 +4520,7 @@
|
||||
|
||||
classCallCheck(this, Layers);
|
||||
|
||||
id$2 = 0;
|
||||
this.art = art;
|
||||
this.add = this.add.bind(this);
|
||||
this.art.option.layers.forEach(function (item) {
|
||||
@@ -4670,13 +4699,12 @@
|
||||
function Setting(art) {
|
||||
classCallCheck(this, Setting);
|
||||
|
||||
id$3 = 0;
|
||||
this.art = art;
|
||||
this.state = false;
|
||||
this.$settings = [];
|
||||
|
||||
if (art.option.setting) {
|
||||
this.init();
|
||||
this.mount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4700,41 +4728,33 @@
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(setting) {
|
||||
value: function add(setting, callback) {
|
||||
var _this$art2 = this.art,
|
||||
refs = _this$art2.refs,
|
||||
i18n = _this$art2.i18n;
|
||||
var option = setting.option;
|
||||
|
||||
if (option && !option.disable) {
|
||||
id$3++;
|
||||
var name = option.name || setting.constructor.name.toLowerCase() || "setting".concat(id$3);
|
||||
var name = option.name || "setting".concat(id$3);
|
||||
var title = option.title || name;
|
||||
var $setting = document.createElement('div');
|
||||
$setting.setAttribute('class', "art-setting art-setting-".concat(name));
|
||||
$setting.dataset.settingIndex = option.index || id$3;
|
||||
append($setting, "<div class=\"art-setting-header\">".concat(this.art.i18n.get(title), "</div>"));
|
||||
append($setting, "<div class=\"art-setting-header\">".concat(i18n.get(title), "</div>"));
|
||||
append($setting, '<div class="art-setting-body"></div>');
|
||||
this.$settings.push($setting);
|
||||
setting.apply && setting.apply(this.art, $setting);
|
||||
this[name] = setting;
|
||||
callback && callback($setting);
|
||||
this[name] = $setting;
|
||||
insertByIndex(refs.$settingBody, $setting, option.index || id$3);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "mount",
|
||||
value: function mount() {
|
||||
var _this2 = this;
|
||||
|
||||
this.$settings.sort(function (a, b) {
|
||||
return Number(a.dataset.settingIndex) - Number(b.dataset.settingIndex);
|
||||
}).forEach(function ($setting) {
|
||||
append(_this2.art.refs.$settingBody, $setting);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "show",
|
||||
value: function show() {
|
||||
var _this$art2 = this.art,
|
||||
$setting = _this$art2.refs.$setting,
|
||||
i18n = _this$art2.i18n,
|
||||
notice = _this$art2.notice;
|
||||
var _this$art3 = this.art,
|
||||
$setting = _this$art3.refs.$setting,
|
||||
i18n = _this$art3.i18n,
|
||||
notice = _this$art3.notice;
|
||||
setStyle($setting, 'display', 'flex');
|
||||
this.state = true;
|
||||
notice.show(i18n.get('Show setting'));
|
||||
@@ -4743,10 +4763,10 @@
|
||||
}, {
|
||||
key: "hide",
|
||||
value: function hide() {
|
||||
var _this$art3 = this.art,
|
||||
$setting = _this$art3.refs.$setting,
|
||||
i18n = _this$art3.i18n,
|
||||
notice = _this$art3.notice;
|
||||
var _this$art4 = this.art,
|
||||
$setting = _this$art4.refs.$setting,
|
||||
i18n = _this$art4.i18n,
|
||||
notice = _this$art4.notice;
|
||||
setStyle($setting, 'display', 'none');
|
||||
this.state = false;
|
||||
notice.show(i18n.get('Hide setting'));
|
||||
@@ -4855,7 +4875,7 @@
|
||||
}, {
|
||||
key: "version",
|
||||
get: function get() {
|
||||
return '1.0.0';
|
||||
return '1.0.2';
|
||||
}
|
||||
}, {
|
||||
key: "config",
|
||||
@@ -4921,7 +4941,7 @@
|
||||
}]);
|
||||
|
||||
return Artplayer;
|
||||
}(_tinyEmitter_2_0_2_tinyEmitter);
|
||||
}(tinyEmitter);
|
||||
|
||||
Artplayer.instances = [];
|
||||
window.Artplayer = Artplayer;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"artplayer.js","sources":["../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/classCallCheck.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/createClass.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/typeof.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/assertThisInitialized.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/possibleConstructorReturn.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/getPrototypeOf.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/setPrototypeOf.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/inherits.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/defineProperty.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/objectSpread.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/arrayWithoutHoles.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/iterableToArray.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/nonIterableSpread.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/toConsumableArray.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/isNativeFunction.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/construct.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/wrapNativeSuper.js","../../src/utils/index.js","../../node_modules/_option-validator@1.1.0@option-validator/dist/option-validator.js","../../src/scheme/validElement.js","../../src/scheme/index.js","../../src/config/mimeCodec.js","../../src/config/mse.js","../../src/config/video.js","../../src/config/index.js","../../node_modules/_tiny-emitter@2.0.2@tiny-emitter/index.js","../../src/template.js","../../src/i18n.js","../../src/player/mountUrlMix.js","../../src/player/attrInit.js","../../src/player/eventInit.js","../../src/player/playMix.js","../../src/player/pauseMin.js","../../src/player/toggleMix.js","../../src/player/seekMix.js","../../src/player/volumeMix.js","../../src/player/currentTimeMix.js","../../src/player/durationMix.js","../../src/player/switchMix.js","../../src/player/playbackRateMix.js","../../src/player/aspectRatioMix.js","../../src/player/screenshotMix.js","../../node_modules/_screenfull@3.3.3@screenfull/dist/screenfull.js","../../src/player/fullscreenMix.js","../../src/player/fullscreenWebMix.js","../../node_modules/_get-size@2.0.3@get-size/get-size.js","../../node_modules/_ev-emitter@1.1.1@ev-emitter/ev-emitter.js","../../node_modules/_unipointer@2.3.0@unipointer/unipointer.js","../../node_modules/_unidragger@2.3.0@unidragger/unidragger.js","../../node_modules/_draggabilly@2.2.0@draggabilly/draggabilly.js","../../src/player/pipMix.js","../../src/player/index.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/arrayWithHoles.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/iterableToArrayLimit.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/nonIterableRest.js","../../node_modules/_@babel_runtime@7.1.5@@babel/runtime/helpers/slicedToArray.js","../../src/icons/index.js","../../src/controls/fullscreen.js","../../src/controls/fullscreenWeb.js","../../src/controls/pip.js","../../src/controls/playAndPause.js","../../src/controls/progress.js","../../src/controls/subtitle.js","../../src/controls/time.js","../../src/controls/volume.js","../../src/controls/setting.js","../../src/controls/thumbnails.js","../../src/controls/screenshot.js","../../src/controls/quality.js","../../src/controls/index.js","../../src/contextmenu/playbackRate.js","../../src/contextmenu/aspectRatio.js","../../src/contextmenu/info.js","../../src/contextmenu/version.js","../../src/contextmenu/close.js","../../src/contextmenu/index.js","../../src/info.js","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.js","../../src/loading.js","../../src/notice.js","../../src/mask.js","../../src/setting/common.js","../../src/setting/index.js","../../src/index.js"],"sourcesContent":["function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck;","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nmodule.exports = _createClass;","function _typeof2(obj) { if Line truncated
|
||||
{"version":3,"file":"artplayer.js","sources":["../../packages/artplayer/node_modules/@babel/runtime/helpers/classCallCheck.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/createClass.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/typeof.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/assertThisInitialized.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/getPrototypeOf.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/setPrototypeOf.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/inherits.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/defineProperty.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/objectSpread.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/iterableToArray.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/nonIterableSpread.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/toConsumableArray.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/isNativeFunction.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/construct.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/wrapNativeSuper.js","../../packages/artplayer/src/utils/index.js","../../packages/artplayer/node_modules/option-validator/dist/option-validator.js","../../packages/artplayer/src/scheme/validElement.js","../../packages/artplayer/src/scheme/validStringEmpty.js","../../packages/artplayer/src/scheme/index.js","../../packages/artplayer/src/config/mimeCodec.js","../../packages/artplayer/src/config/mse.js","../../packages/artplayer/src/config/video.js","../../packages/artplayer/src/config/index.js","../../packages/artplayer/node_modules/tiny-emitter/index.js","../../packages/artplayer/src/template.js","../../packages/artplayer/src/i18n.js","../../packages/artplayer/src/player/mountUrlMix.js","../../packages/artplayer/src/player/attrInit.js","../../packages/artplayer/src/player/eventInit.js","../../packages/artplayer/src/player/playMix.js","../../packages/artplayer/src/player/pauseMin.js","../../packages/artplayer/src/player/toggleMix.js","../../packages/artplayer/src/player/seekMix.js","../../packages/artplayer/src/player/volumeMix.js","../../packages/artplayer/src/player/currentTimeMix.js","../../packages/artplayer/src/player/durationMix.js","../../packages/artplayer/src/player/switchMix.js","../../packages/artplayer/src/player/playbackRateMix.js","../../packages/artplayer/src/player/aspectRatioMix.js","../../packages/artplayer/src/player/screenshotMix.js","../../packages/artplayer/node_modules/screenfull/dist/screenfull.js","../../packages/artplayer/src/player/fullscreenMix.js","../../packages/artplayer/src/player/fullscreenWebMix.js","../../packages/artplayer/node_modules/get-size/get-size.js","../../packages/artplayer/node_modules/ev-emitter/ev-emitter.js","../../packages/artplayer/node_modules/unipointer/unipointer.js","../../packages/artplayer/node_modules/unidragger/unidragger.js","../../packages/artplayer/node_modules/draggabilly/draggabilly.js","../../packages/artplayer/src/player/pipMix.js","../../packages/artplayer/src/player/index.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/arrayWithHoles.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/nonIterableRest.js","../../packages/artplayer/node_modules/@babel/runtime/helpers/slicedToArray.js","../../packages/artplayer/src/icons/index.js","../../packages/artplayer/src/controls/fullscreen.js","../../packages/artplayer/src/controls/fullscreenWeb.js","../../packages/artplayer/src/controls/pip.js","../../packages/artplayer/src/controls/playAndPause.js","../../packages/artplayer/src/controls/progress.js","../../packages/artplayer/src/controls/subtitle.js","../../packages/artplayer/src/controls/time.js","../../packages/artplayer/src/controls/volume.js","../../packages/artplayer/src/controls/setting.js","../../packages/artplayer/src/controls/thumbnails.js","../../packages/artplayer/src/controls/screenshot.js","../../packages/artplayer/src/controls/quality.js","../../packages/artplayer/src/controls/index.js","../../packages/artplayer/src/contextmenu/playbackRate.js","../../packages/artplayer/src/contextmenu/aspectRatio.js","../../packages/artplayer/src/contextmenu/info.js","../../packages/artplayer/src/contextmenu/version.js","../../packages/artplayer/src/contextmenu/close.js","../../packages/artplayer/src/contextmenu/index.js","../../packages/artplayer/src/info.js","../../packages/artplayer/src/subtitle.js","../../packages/artplayer/src/events.js","../../packages/artplayer/src/hotkey.js","../../packages/artplayer/src/layers.js","../../packages/artplayer/src/loaLine truncated
|
||||
@@ -0,0 +1,41 @@
|
||||
var controlMap = {};
|
||||
function creatCodeMirror(id, value) {
|
||||
var mirror = CodeMirror(document.querySelector(`[data-control="${id}"]`), {
|
||||
lineNumbers: true,
|
||||
mode: 'javascript',
|
||||
matchBrackets: true,
|
||||
value: value.trim()
|
||||
});
|
||||
controlMap[Number(id)] = mirror;
|
||||
return mirror;
|
||||
}
|
||||
|
||||
function initApp(app) {
|
||||
console.log(app);
|
||||
}
|
||||
|
||||
var $error = document.querySelector('.error-tip');
|
||||
Array.from(document.querySelectorAll('.run')).forEach(function (item) {
|
||||
item.addEventListener('click', function (e) {
|
||||
try {
|
||||
Artplayer.instances.forEach(ins => {
|
||||
ins.destroy(true)
|
||||
});;
|
||||
var id = Number(e.target.dataset.id);
|
||||
eval(controlMap[id].getValue());
|
||||
initApp(Artplayer.instances[0]);
|
||||
$error.innerHTML = '';
|
||||
} catch (error) {
|
||||
var msg = error.message.trim();
|
||||
$error.innerHTML = '请打开控制台:' + msg;
|
||||
console.error(msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
creatCodeMirror(1, `
|
||||
new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: 'https://blog.zhw-island.com/assets-cdn/video/one-more-time-one-more-chance-480p.mp4'
|
||||
});
|
||||
`);
|
||||
Reference in new issue
Block a user