mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
add attrMix.js
This commit is contained in:
1 parent
1438ce5e82
commit
938e8718bc
12 files changed
+268
-232
No files matched your search
+218
-200
@@ -860,7 +860,6 @@
|
||||
value: function desktop() {
|
||||
var _this$art$option = this.art.option,
|
||||
backdrop = _this$art$option.backdrop,
|
||||
theme = _this$art$option.theme,
|
||||
useSSR = _this$art$option.useSSR;
|
||||
|
||||
if (!useSSR) {
|
||||
@@ -893,7 +892,6 @@
|
||||
this.$miniTitle = this.query('.art-mini-title');
|
||||
this.$miniClose = this.query('.art-mini-close');
|
||||
this.$contextmenu = this.query('.art-contextmenus');
|
||||
this.$player.style.setProperty('--theme', theme);
|
||||
this.$container.dataset.artId = this.art.id;
|
||||
|
||||
if (backdrop) {
|
||||
@@ -1117,190 +1115,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
function attrInit(art) {
|
||||
var option = art.option,
|
||||
storage = art.storage,
|
||||
_art$template = art.template,
|
||||
$video = _art$template.$video,
|
||||
$poster = _art$template.$poster;
|
||||
Object.keys(option.moreVideoAttr).forEach(function (key) {
|
||||
$video[key] = option.moreVideoAttr[key];
|
||||
});
|
||||
|
||||
if (option.muted) {
|
||||
$video.muted = option.muted;
|
||||
}
|
||||
|
||||
if (option.volume) {
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
}
|
||||
|
||||
var volume = storage.get('volume');
|
||||
|
||||
if (volume) {
|
||||
$video.volume = clamp(volume, 0, 1);
|
||||
}
|
||||
|
||||
if (option.poster) {
|
||||
// $video.poster = option.poster;
|
||||
setStyle($poster, 'backgroundImage', "url(".concat(option.poster, ")"));
|
||||
}
|
||||
|
||||
if (option.autoplay) {
|
||||
$video.autoplay = option.autoplay;
|
||||
}
|
||||
|
||||
$video.controls = false;
|
||||
|
||||
if (option.ads.length === 0) {
|
||||
art.url = option.url;
|
||||
}
|
||||
}
|
||||
|
||||
function eventInit(art) {
|
||||
var option = art.option,
|
||||
proxy = art.events.proxy,
|
||||
_art$template = art.template,
|
||||
$player = _art$template.$player,
|
||||
$video = _art$template.$video,
|
||||
$poster = _art$template.$poster,
|
||||
i18n = art.i18n,
|
||||
notice = art.notice;
|
||||
var reconnectTime = 0;
|
||||
var maxReconnectTime = 5;
|
||||
proxy($video, 'click', function () {
|
||||
art.toggle();
|
||||
});
|
||||
proxy($video, 'dblclick', function () {
|
||||
art.fullscreen = !art.fullscreen;
|
||||
});
|
||||
config.events.forEach(function (eventName) {
|
||||
proxy($video, eventName, function (event) {
|
||||
art.emit("video:".concat(event.type), event);
|
||||
});
|
||||
}); // art.on('video:abort', () => {
|
||||
// });
|
||||
|
||||
art.on('video:canplay', function () {
|
||||
reconnectTime = 0;
|
||||
art.loading.show = false;
|
||||
});
|
||||
art.once('video:canplay', function () {
|
||||
art.loading.show = false;
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
art.isReady = true;
|
||||
art.emit('ready');
|
||||
}); // art.on('video:canplaythrough', () => {
|
||||
// });
|
||||
// art.on('video:durationchange', () => {
|
||||
// });
|
||||
// art.on('video:emptied', () => {
|
||||
// });
|
||||
|
||||
art.on('video:ended', function () {
|
||||
if (option.loop) {
|
||||
art.seek = 0;
|
||||
art.play();
|
||||
art.controls.show = false;
|
||||
art.mask.show = false;
|
||||
} else {
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
}
|
||||
});
|
||||
art.on('video:error', function () {
|
||||
if (reconnectTime < maxReconnectTime) {
|
||||
sleep(1000).then(function () {
|
||||
reconnectTime += 1;
|
||||
art.url = option.url;
|
||||
notice.show = "".concat(i18n.get('Reconnect'), ": ").concat(reconnectTime);
|
||||
art.emit('error', reconnectTime);
|
||||
});
|
||||
} else {
|
||||
art.loading.show = false;
|
||||
art.controls.show = false;
|
||||
addClass($player, 'art-error');
|
||||
sleep(1000).then(function () {
|
||||
notice.show = i18n.get('Video load failed');
|
||||
art.destroy(false);
|
||||
});
|
||||
}
|
||||
}); // art.on('video:loadeddata', () => {
|
||||
// });
|
||||
|
||||
art.once('video:loadedmetadata', function () {
|
||||
art.autoSize = option.autoSize;
|
||||
|
||||
if (isMobile) {
|
||||
art.loading.show = false;
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
}
|
||||
});
|
||||
art.on('video:loadstart', function () {
|
||||
art.loading.show = true;
|
||||
});
|
||||
art.on('video:pause', function () {
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
});
|
||||
art.on('video:play', function () {
|
||||
art.mask.show = false;
|
||||
setStyle($poster, 'display', 'none');
|
||||
});
|
||||
art.on('video:playing', function () {
|
||||
art.mask.show = false;
|
||||
}); // art.on('video:progress', () => {
|
||||
// });
|
||||
// art.on('video:ratechange', () => {
|
||||
// });
|
||||
|
||||
art.on('video:seeked', function () {
|
||||
art.loading.show = false;
|
||||
});
|
||||
art.on('video:seeking', function () {
|
||||
art.loading.show = true;
|
||||
}); // art.on('video:stalled', () => {
|
||||
// });
|
||||
// art.on('video:suspend', () => {
|
||||
// });
|
||||
|
||||
art.on('video:timeupdate', function () {
|
||||
art.mask.show = false;
|
||||
}); // art.on('video:volumechange', () => {
|
||||
// });
|
||||
|
||||
art.on('video:waiting', function () {
|
||||
art.loading.show = true;
|
||||
});
|
||||
}
|
||||
|
||||
function exclusiveInit(art) {
|
||||
var sizeProps = ['mini', 'pip', 'fullscreen', 'fullscreenWeb'];
|
||||
|
||||
function exclusive(props) {
|
||||
props.forEach(function (name) {
|
||||
art.on(name, function () {
|
||||
if (art[name]) {
|
||||
props.filter(function (item) {
|
||||
return item !== name;
|
||||
}).forEach(function (item) {
|
||||
if (art[item]) {
|
||||
art[item] = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exclusive(sizeProps);
|
||||
def(art, 'normalSize', {
|
||||
get: function get() {
|
||||
return sizeProps.every(function (name) {
|
||||
return !art[name];
|
||||
});
|
||||
function attrMix(art) {
|
||||
var $video = art.template.$video;
|
||||
def(art, 'attr', {
|
||||
value: function value(key, _value) {
|
||||
if (_value === undefined) return $video[key];
|
||||
$video[key] = _value;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2385,7 +2205,7 @@
|
||||
$player = art.template.$player;
|
||||
def(art, 'theme', {
|
||||
get: function get() {
|
||||
return $player.style.getProperty('--theme');
|
||||
return getComputedStyle($player).getPropertyValue('--theme');
|
||||
},
|
||||
set: function set(theme) {
|
||||
option.theme = theme;
|
||||
@@ -2405,13 +2225,200 @@
|
||||
});
|
||||
}
|
||||
|
||||
function exclusiveMix(art) {
|
||||
var sizeProps = ['mini', 'pip', 'fullscreen', 'fullscreenWeb'];
|
||||
|
||||
function exclusive(props) {
|
||||
props.forEach(function (name) {
|
||||
art.on(name, function () {
|
||||
if (art[name]) {
|
||||
props.filter(function (item) {
|
||||
return item !== name;
|
||||
}).forEach(function (item) {
|
||||
if (art[item]) {
|
||||
art[item] = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exclusive(sizeProps);
|
||||
def(art, 'normalSize', {
|
||||
get: function get() {
|
||||
return sizeProps.every(function (name) {
|
||||
return !art[name];
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function attrInit(art) {
|
||||
var option = art.option,
|
||||
storage = art.storage,
|
||||
_art$template = art.template,
|
||||
$video = _art$template.$video,
|
||||
$poster = _art$template.$poster;
|
||||
Object.keys(option.moreVideoAttr).forEach(function (key) {
|
||||
art.attr(key, option.moreVideoAttr[key]);
|
||||
});
|
||||
|
||||
if (option.muted) {
|
||||
art.muted = option.muted;
|
||||
}
|
||||
|
||||
if (option.volume) {
|
||||
art.volume = clamp(option.volume, 0, 1);
|
||||
}
|
||||
|
||||
var volume = storage.get('volume');
|
||||
|
||||
if (volume) {
|
||||
art.volume = clamp(volume, 0, 1);
|
||||
}
|
||||
|
||||
if (option.poster) {
|
||||
setStyle($poster, 'backgroundImage', "url(".concat(option.poster, ")"));
|
||||
}
|
||||
|
||||
if (option.autoplay) {
|
||||
$video.autoplay = option.autoplay;
|
||||
}
|
||||
|
||||
if (option.theme) {
|
||||
art.theme = option.theme;
|
||||
}
|
||||
|
||||
if (option.ads.length === 0) {
|
||||
art.url = option.url;
|
||||
}
|
||||
}
|
||||
|
||||
function eventInit(art) {
|
||||
var option = art.option,
|
||||
proxy = art.events.proxy,
|
||||
_art$template = art.template,
|
||||
$player = _art$template.$player,
|
||||
$video = _art$template.$video,
|
||||
$poster = _art$template.$poster,
|
||||
i18n = art.i18n,
|
||||
notice = art.notice;
|
||||
var reconnectTime = 0;
|
||||
var maxReconnectTime = 5;
|
||||
proxy($video, 'click', function () {
|
||||
art.toggle();
|
||||
});
|
||||
proxy($video, 'dblclick', function () {
|
||||
art.fullscreen = !art.fullscreen;
|
||||
});
|
||||
config.events.forEach(function (eventName) {
|
||||
proxy($video, eventName, function (event) {
|
||||
art.emit("video:".concat(event.type), event);
|
||||
});
|
||||
}); // art.on('video:abort', () => {
|
||||
// });
|
||||
|
||||
art.on('video:canplay', function () {
|
||||
reconnectTime = 0;
|
||||
art.loading.show = false;
|
||||
});
|
||||
art.once('video:canplay', function () {
|
||||
art.loading.show = false;
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
art.isReady = true;
|
||||
art.emit('ready');
|
||||
}); // art.on('video:canplaythrough', () => {
|
||||
// });
|
||||
// art.on('video:durationchange', () => {
|
||||
// });
|
||||
// art.on('video:emptied', () => {
|
||||
// });
|
||||
|
||||
art.on('video:ended', function () {
|
||||
if (option.loop) {
|
||||
art.seek = 0;
|
||||
art.play();
|
||||
art.controls.show = false;
|
||||
art.mask.show = false;
|
||||
} else {
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
}
|
||||
});
|
||||
art.on('video:error', function () {
|
||||
if (reconnectTime < maxReconnectTime) {
|
||||
sleep(1000).then(function () {
|
||||
reconnectTime += 1;
|
||||
art.url = option.url;
|
||||
notice.show = "".concat(i18n.get('Reconnect'), ": ").concat(reconnectTime);
|
||||
art.emit('error', reconnectTime);
|
||||
});
|
||||
} else {
|
||||
art.loading.show = false;
|
||||
art.controls.show = false;
|
||||
addClass($player, 'art-error');
|
||||
sleep(1000).then(function () {
|
||||
notice.show = i18n.get('Video load failed');
|
||||
art.destroy(false);
|
||||
});
|
||||
}
|
||||
}); // art.on('video:loadeddata', () => {
|
||||
// });
|
||||
|
||||
art.once('video:loadedmetadata', function () {
|
||||
art.autoSize = option.autoSize;
|
||||
|
||||
if (isMobile) {
|
||||
art.loading.show = false;
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
}
|
||||
});
|
||||
art.on('video:loadstart', function () {
|
||||
art.loading.show = true;
|
||||
});
|
||||
art.on('video:pause', function () {
|
||||
art.controls.show = true;
|
||||
art.mask.show = true;
|
||||
});
|
||||
art.on('video:play', function () {
|
||||
art.mask.show = false;
|
||||
setStyle($poster, 'display', 'none');
|
||||
});
|
||||
art.on('video:playing', function () {
|
||||
art.mask.show = false;
|
||||
}); // art.on('video:progress', () => {
|
||||
// });
|
||||
// art.on('video:ratechange', () => {
|
||||
// });
|
||||
|
||||
art.on('video:seeked', function () {
|
||||
art.loading.show = false;
|
||||
});
|
||||
art.on('video:seeking', function () {
|
||||
art.loading.show = true;
|
||||
}); // art.on('video:stalled', () => {
|
||||
// });
|
||||
// art.on('video:suspend', () => {
|
||||
// });
|
||||
|
||||
art.on('video:timeupdate', function () {
|
||||
art.mask.show = false;
|
||||
}); // art.on('video:volumechange', () => {
|
||||
// });
|
||||
|
||||
art.on('video:waiting', function () {
|
||||
art.loading.show = true;
|
||||
});
|
||||
}
|
||||
|
||||
var Player = function Player(art) {
|
||||
_classCallCheck(this, Player);
|
||||
|
||||
urlMix(art);
|
||||
eventInit(art);
|
||||
attrInit(art);
|
||||
exclusiveInit(art);
|
||||
attrMix(art);
|
||||
playMix(art);
|
||||
pauseMix(art);
|
||||
toggleMix(art);
|
||||
@@ -2439,6 +2446,9 @@
|
||||
autoHeightMix(art);
|
||||
themeMix(art);
|
||||
titleMix(art);
|
||||
exclusiveMix(art);
|
||||
eventInit(art);
|
||||
attrInit(art);
|
||||
};
|
||||
|
||||
function _superPropBase(object, property) {
|
||||
@@ -4049,9 +4059,6 @@
|
||||
_createClass(Hotkey, [{
|
||||
key: "add",
|
||||
value: function add(key, event) {
|
||||
errorHandle(typeof key === 'number', 'The Hotkey.add() first parameter is not a number');
|
||||
errorHandle(typeof event === 'function', 'The Hotkey.add() second parameter is not a function');
|
||||
|
||||
if (this.keys[key]) {
|
||||
this.keys[key].push(event);
|
||||
} else {
|
||||
@@ -4060,6 +4067,17 @@
|
||||
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "remove",
|
||||
value: function remove(key, event) {
|
||||
if (this.keys[key]) {
|
||||
var index = this.keys[key].indexOf(event);
|
||||
|
||||
if (index !== -1) {
|
||||
this.keys[key].splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
return Hotkey;
|
||||
@@ -4542,14 +4560,16 @@
|
||||
|
||||
function localVideo(art) {
|
||||
var proxy = art.events.proxy,
|
||||
template = art.template,
|
||||
_art$template = art.template,
|
||||
$video = _art$template.$video,
|
||||
$player = _art$template.$player,
|
||||
option = art.option,
|
||||
setting = art.setting,
|
||||
i18n = art.i18n;
|
||||
|
||||
function loadVideo(file) {
|
||||
if (file) {
|
||||
var canPlayType = template.$video.canPlayType(file.type);
|
||||
var canPlayType = $video.canPlayType(file.type);
|
||||
|
||||
if (canPlayType === 'maybe' || canPlayType === 'probably') {
|
||||
var url = URL.createObjectURL(file);
|
||||
@@ -4562,12 +4582,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
proxy(template.$player, 'dragover', function (event) {
|
||||
proxy($player, 'dragover', function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
proxy(template.$player, 'drop', function (event) {
|
||||
proxy($player, 'drop', function (event) {
|
||||
event.preventDefault();
|
||||
var file = e.dataTransfer.files[0];
|
||||
var file = event.dataTransfer.files[0];
|
||||
loadVideo(file);
|
||||
});
|
||||
|
||||
@@ -4739,7 +4759,6 @@
|
||||
key: "add",
|
||||
value: function add(plugin) {
|
||||
this.id += 1;
|
||||
errorHandle(typeof plugin === 'function', "The Plugins.add() first parameter is not a function");
|
||||
var result = plugin.call(this, this.art);
|
||||
var pluginName = result && result.name || plugin.name || "plugin".concat(this.id);
|
||||
errorHandle(!has(this, pluginName), "Cannot add a plugin that already has the same name: ".concat(pluginName));
|
||||
@@ -4858,7 +4877,6 @@
|
||||
$video.autoplay = option.autoplay;
|
||||
}
|
||||
|
||||
$video.controls = true;
|
||||
var typeName = option.type || getExt(option.url);
|
||||
var typeCallback = option.customType[typeName];
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"artplayer.js","sources":["../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/classCallCheck.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/createClass.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/assertThisInitialized.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/setPrototypeOf.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/inherits.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/typeof.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/possibleConstructorReturn.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/getPrototypeOf.js","../../node_modules/_style-inject@0.3.0@style-inject/dist/style-inject.es.js","../../packages/artplayer/node_modules/_option-validator@2.0.6@option-validator/dist/option-validator.js","../../packages/artplayer/src/utils/emitter.js","../../packages/artplayer/src/utils/compatibility.js","../../packages/artplayer/src/utils/dom.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/isNativeFunction.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/isNativeReflectConstruct.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/construct.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/wrapNativeSuper.js","../../packages/artplayer/src/utils/error.js","../../packages/artplayer/src/utils/subtitle.js","../../packages/artplayer/src/utils/file.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/arrayLikeToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/arrayWithoutHoles.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/iterableToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/nonIterableSpread.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/toConsumableArray.js","../../packages/artplayer/src/utils/property.js","../../packages/artplayer/src/utils/time.js","../../packages/artplayer/src/utils/format.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/defineProperty.js","../../packages/artplayer/src/scheme/index.js","../../packages/artplayer/src/config/index.js","../../packages/artplayer/src/whitelist.js","../../packages/artplayer/src/template.js","../../packages/artplayer/src/i18n/index.js","../../packages/artplayer/src/player/urlMix.js","../../packages/artplayer/src/player/attrInit.js","../../packages/artplayer/src/player/eventInit.js","../../packages/artplayer/src/player/exclusiveInit.js","../../packages/artplayer/src/player/playMix.js","../../packages/artplayer/src/player/pauseMix.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@5.0.2@screenfull/dist/screenfull.js","../../packages/artplayer/src/player/fullscreenMix.js","../../packages/artplayer/src/player/fullscreenWebMix.js","../../packages/artplayer/src/player/pipMix.js","../../packages/artplayer/src/player/loadedMix.js","../../packages/artplayer/src/player/playedMix.js","../../packages/artplayer/src/player/playingMix.js","../../packages/artplayer/src/player/autoSizeMix.js","../../packages/artplayer/src/player/rectMix.js","../../packages/artplayer/src/player/flipMix.js","../../packages/artplayer/src/player/miniMix.js","../../packages/artplayer/src/player/loopMix.js","../../packages/artplayer/src/player/rotateMix.js","../../packages/artplayer/src/player/posterMix.js","../../packages/artplayer/src/player/autoHeightMix.js","../../packages/artplayer/src/player/themeMix.js","../../packages/artplayer/src/player/titleMix.js","../../packages/artplayer/src/player/index.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/superPropBase.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/get.js","../../packages/artplayer/src/utils/component.js","../../packages/artplayer/src/control/fullscreen.js","../../packages/artplayer/src/control/fullscreenWeb.js","../../packages/artplayer/src/control/pip.js","../../packages/artplayer/src/control/playAndPause.js","../../packages/artplayer/src/control/progress.js","../../packages/artplayer/src/control/subtitle.js","../../packages/artplayer/src/control/time.js","../../packages/artplayer/src/control/volume.js","../../packages/artplayer/src/Line truncated
|
||||
{"version":3,"file":"artplayer.js","sources":["../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/classCallCheck.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/createClass.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/assertThisInitialized.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/setPrototypeOf.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/inherits.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/typeof.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/possibleConstructorReturn.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/getPrototypeOf.js","../../node_modules/_style-inject@0.3.0@style-inject/dist/style-inject.es.js","../../packages/artplayer/node_modules/_option-validator@2.0.6@option-validator/dist/option-validator.js","../../packages/artplayer/src/utils/emitter.js","../../packages/artplayer/src/utils/compatibility.js","../../packages/artplayer/src/utils/dom.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/isNativeFunction.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/isNativeReflectConstruct.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/construct.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/wrapNativeSuper.js","../../packages/artplayer/src/utils/error.js","../../packages/artplayer/src/utils/subtitle.js","../../packages/artplayer/src/utils/file.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/arrayLikeToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/arrayWithoutHoles.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/iterableToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/nonIterableSpread.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/toConsumableArray.js","../../packages/artplayer/src/utils/property.js","../../packages/artplayer/src/utils/time.js","../../packages/artplayer/src/utils/format.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/defineProperty.js","../../packages/artplayer/src/scheme/index.js","../../packages/artplayer/src/config/index.js","../../packages/artplayer/src/whitelist.js","../../packages/artplayer/src/template.js","../../packages/artplayer/src/i18n/index.js","../../packages/artplayer/src/player/urlMix.js","../../packages/artplayer/src/player/attrMix.js","../../packages/artplayer/src/player/playMix.js","../../packages/artplayer/src/player/pauseMix.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@5.0.2@screenfull/dist/screenfull.js","../../packages/artplayer/src/player/fullscreenMix.js","../../packages/artplayer/src/player/fullscreenWebMix.js","../../packages/artplayer/src/player/pipMix.js","../../packages/artplayer/src/player/loadedMix.js","../../packages/artplayer/src/player/playedMix.js","../../packages/artplayer/src/player/playingMix.js","../../packages/artplayer/src/player/autoSizeMix.js","../../packages/artplayer/src/player/rectMix.js","../../packages/artplayer/src/player/flipMix.js","../../packages/artplayer/src/player/miniMix.js","../../packages/artplayer/src/player/loopMix.js","../../packages/artplayer/src/player/rotateMix.js","../../packages/artplayer/src/player/posterMix.js","../../packages/artplayer/src/player/autoHeightMix.js","../../packages/artplayer/src/player/themeMix.js","../../packages/artplayer/src/player/titleMix.js","../../packages/artplayer/src/player/exclusiveMix.js","../../packages/artplayer/src/player/optionInit.js","../../packages/artplayer/src/player/eventInit.js","../../packages/artplayer/src/player/index.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/superPropBase.js","../../node_modules/_@babel_runtime@7.16.3@@babel/runtime/helpers/esm/get.js","../../packages/artplayer/src/utils/component.js","../../packages/artplayer/src/control/fullscreen.js","../../packages/artplayer/src/control/fullscreenWeb.js","../../packages/artplayer/src/control/pip.js","../../packages/artplayer/src/control/playAndPause.js","../../packages/artplayer/src/control/progress.js","../../packages/artplayer/src/control/subtitle.js","../../packages/artplayer/src/control/time.js","../../packages/artplayer/srcLine truncated
|
||||
@@ -1,5 +1,3 @@
|
||||
import { errorHandle } from './utils';
|
||||
|
||||
export default class Hotkey {
|
||||
constructor(art) {
|
||||
this.keys = {};
|
||||
@@ -56,8 +54,6 @@ export default class Hotkey {
|
||||
}
|
||||
|
||||
add(key, event) {
|
||||
errorHandle(typeof key === 'number', 'The Hotkey.add() first parameter is not a number');
|
||||
errorHandle(typeof event === 'function', 'The Hotkey.add() second parameter is not a function');
|
||||
if (this.keys[key]) {
|
||||
this.keys[key].push(event);
|
||||
} else {
|
||||
@@ -65,4 +61,13 @@ export default class Hotkey {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
remove(key, event) {
|
||||
if (this.keys[key]) {
|
||||
const index = this.keys[key].indexOf(event);
|
||||
if (index !== -1) {
|
||||
this.keys[key].splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,13 @@ export default class Mobile {
|
||||
template: { $video },
|
||||
} = art;
|
||||
|
||||
config.events.forEach(eventName => {
|
||||
proxy($video, eventName, event => {
|
||||
config.events.forEach((eventName) => {
|
||||
proxy($video, eventName, (event) => {
|
||||
art.emit(`video:${event.type}`, event);
|
||||
});
|
||||
});
|
||||
|
||||
Object.keys(option.moreVideoAttr).forEach(key => {
|
||||
Object.keys(option.moreVideoAttr).forEach((key) => {
|
||||
$video[key] = option.moreVideoAttr[key];
|
||||
});
|
||||
|
||||
@@ -35,8 +35,6 @@ export default class Mobile {
|
||||
$video.autoplay = option.autoplay;
|
||||
}
|
||||
|
||||
$video.controls = true;
|
||||
|
||||
const typeName = option.type || getExt(option.url);
|
||||
const typeCallback = option.customType[typeName];
|
||||
if (typeName && typeCallback) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { def } from '../utils';
|
||||
|
||||
export default function attrMix(art) {
|
||||
const {
|
||||
template: { $video },
|
||||
} = art;
|
||||
|
||||
def(art, 'attr', {
|
||||
value(key, value) {
|
||||
if (value === undefined) return $video[key];
|
||||
$video[key] = value;
|
||||
},
|
||||
});
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { def } from '../utils';
|
||||
|
||||
export default function exclusiveInit(art) {
|
||||
export default function exclusiveMix(art) {
|
||||
const sizeProps = ['mini', 'pip', 'fullscreen', 'fullscreenWeb'];
|
||||
|
||||
function exclusive(props) {
|
||||
@@ -1,7 +1,5 @@
|
||||
import urlMix from './urlMix';
|
||||
import attrInit from './attrInit';
|
||||
import eventInit from './eventInit';
|
||||
import exclusiveInit from './exclusiveInit';
|
||||
import attrMix from './attrMix';
|
||||
import playMix from './playMix';
|
||||
import pauseMix from './pauseMix';
|
||||
import toggleMix from './toggleMix';
|
||||
@@ -29,13 +27,14 @@ import posterMix from './posterMix';
|
||||
import autoHeightMix from './autoHeightMix';
|
||||
import themeMix from './themeMix';
|
||||
import titleMix from './titleMix';
|
||||
import exclusiveMix from './exclusiveMix';
|
||||
import optionInit from './optionInit';
|
||||
import eventInit from './eventInit';
|
||||
|
||||
export default class Player {
|
||||
constructor(art) {
|
||||
urlMix(art);
|
||||
eventInit(art);
|
||||
attrInit(art);
|
||||
exclusiveInit(art);
|
||||
attrMix(art);
|
||||
playMix(art);
|
||||
pauseMix(art);
|
||||
toggleMix(art);
|
||||
@@ -63,5 +62,8 @@ export default class Player {
|
||||
autoHeightMix(art);
|
||||
themeMix(art);
|
||||
titleMix(art);
|
||||
exclusiveMix(art);
|
||||
eventInit(art);
|
||||
optionInit(art);
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -8,24 +8,23 @@ export default function attrInit(art) {
|
||||
} = art;
|
||||
|
||||
Object.keys(option.moreVideoAttr).forEach((key) => {
|
||||
$video[key] = option.moreVideoAttr[key];
|
||||
art.attr(key, option.moreVideoAttr[key]);
|
||||
});
|
||||
|
||||
if (option.muted) {
|
||||
$video.muted = option.muted;
|
||||
art.muted = option.muted;
|
||||
}
|
||||
|
||||
if (option.volume) {
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
art.volume = clamp(option.volume, 0, 1);
|
||||
}
|
||||
|
||||
const volume = storage.get('volume');
|
||||
if (volume) {
|
||||
$video.volume = clamp(volume, 0, 1);
|
||||
art.volume = clamp(volume, 0, 1);
|
||||
}
|
||||
|
||||
if (option.poster) {
|
||||
// $video.poster = option.poster;
|
||||
setStyle($poster, 'backgroundImage', `url(${option.poster})`);
|
||||
}
|
||||
|
||||
@@ -33,7 +32,9 @@ export default function attrInit(art) {
|
||||
$video.autoplay = option.autoplay;
|
||||
}
|
||||
|
||||
$video.controls = false;
|
||||
if (option.theme) {
|
||||
art.theme = option.theme;
|
||||
}
|
||||
|
||||
if (option.ads.length === 0) {
|
||||
art.url = option.url;
|
||||
@@ -8,7 +8,7 @@ export default function themeMix(art) {
|
||||
|
||||
def(art, 'theme', {
|
||||
get() {
|
||||
return $player.style.getProperty('--theme');
|
||||
return getComputedStyle($player).getPropertyValue('--theme');
|
||||
},
|
||||
set(theme) {
|
||||
option.theme = theme;
|
||||
|
||||
@@ -34,7 +34,6 @@ export default class Plugins {
|
||||
|
||||
add(plugin) {
|
||||
this.id += 1;
|
||||
errorHandle(typeof plugin === 'function', `The Plugins.add() first parameter is not a function`);
|
||||
const result = plugin.call(this, this.art);
|
||||
const pluginName = (result && result.name) || plugin.name || `plugin${this.id}`;
|
||||
errorHandle(!has(this, pluginName), `Cannot add a plugin that already has the same name: ${pluginName}`);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { append, query, setStyle, setStyles, errorHandle } from '../utils';
|
||||
export default function localVideo(art) {
|
||||
const {
|
||||
events: { proxy },
|
||||
template,
|
||||
template: { $video, $player },
|
||||
option,
|
||||
setting,
|
||||
i18n,
|
||||
@@ -11,7 +11,7 @@ export default function localVideo(art) {
|
||||
|
||||
function loadVideo(file) {
|
||||
if (file) {
|
||||
const canPlayType = template.$video.canPlayType(file.type);
|
||||
const canPlayType = $video.canPlayType(file.type);
|
||||
if (canPlayType === 'maybe' || canPlayType === 'probably') {
|
||||
const url = URL.createObjectURL(file);
|
||||
option.title = file.name;
|
||||
@@ -23,13 +23,13 @@ export default function localVideo(art) {
|
||||
}
|
||||
}
|
||||
|
||||
proxy(template.$player, 'dragover', (event) => {
|
||||
proxy($player, 'dragover', (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
proxy(template.$player, 'drop', (event) => {
|
||||
proxy($player, 'drop', (event) => {
|
||||
event.preventDefault();
|
||||
const file = e.dataTransfer.files[0];
|
||||
const file = event.dataTransfer.files[0];
|
||||
loadVideo(file);
|
||||
});
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ export default class Template {
|
||||
}
|
||||
|
||||
desktop() {
|
||||
const { backdrop, theme, useSSR } = this.art.option;
|
||||
const { backdrop, useSSR } = this.art.option;
|
||||
|
||||
if (!useSSR) {
|
||||
this.$container.innerHTML = Template.html;
|
||||
@@ -135,7 +135,6 @@ export default class Template {
|
||||
this.$miniClose = this.query('.art-mini-close');
|
||||
this.$contextmenu = this.query('.art-contextmenus');
|
||||
|
||||
this.$player.style.setProperty('--theme', theme);
|
||||
this.$container.dataset.artId = this.art.id;
|
||||
|
||||
if (backdrop) {
|
||||
|
||||
Reference in new issue
Block a user