mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -08:00
移除大部分异步操作
This commit is contained in:
1 parent
3fb41eedf7
commit
450e4ac879
8 files changed
+82
-90
No files matched your search
+38
-41
@@ -773,7 +773,7 @@
|
|||||||
createClass(Template, [{
|
createClass(Template, [{
|
||||||
key: "init",
|
key: "init",
|
||||||
value: function init() {
|
value: function init() {
|
||||||
this.$container.innerHTML = "\n <div class=\"artplayer-video-player\">\n <video data-index=\"10\" class=\"artplayer-video\"></video>\n <div data-index=\"20\" class=\"artplayer-subtitle\"></div>\n <div data-index=\"30\" class=\"artplayer-layers\"></div>\n <div data-index=\"40\" class=\"artplayer-mask\"></div>\n <div data-index=\"50\" class=\"artplayer-bottom\">\n <div class=\"artplayer-progress\"></div>\n <div class=\"artplayer-controls\">\n <div class=\"artplayer-controls-left\"></div>\n <div class=\"artplayer-controls-right\"></div>\n </div>\n </div>\n <div data-index=\"60\" class=\"artplayer-loading\"></div>\n <div data-index=\"70\" class=\"artplayer-notice\">\n <div class=\"artplayer-notice-inner\"></div>\n </div>\n <div data-index=\"80\" class=\"artplayer-setting\">\n <div class=\"artplayer-setting-inner\">\n <div class=\"artplayer-setting-body\"></div>\n <div class=\"artplayer-setting-close\">\xD7</div>\n </div>\n </div>\n <div data-index=\"90\" class=\"artplayer-info\">\n <div class=\"artplayer-info-panel\"></div>\n <div class=\"artplayer-info-close\">[x]</div>\n </div>\n <div data-index=\"100\" class=\"artplayer-pip-header\">\n <div class=\"artplayer-pip-title\"></div>\n <div class=\"artplayer-pip-close\">\xD7</div>\n </div>\n <div data-index=\"110\" class=\"artplayer-contextmenu\"></div>\n </div>\n ";
|
this.$container.innerHTML = "\n <div class=\"artplayer-video-player\">\n <video class=\"artplayer-video\"></video>\n <div class=\"artplayer-subtitle\"></div>\n <div class=\"artplayer-layers\"></div>\n <div class=\"artplayer-mask\"></div>\n <div class=\"artplayer-bottom\">\n <div class=\"artplayer-progress\"></div>\n <div class=\"artplayer-controls\">\n <div class=\"artplayer-controls-left\"></div>\n <div class=\"artplayer-controls-right\"></div>\n </div>\n </div>\n <div class=\"artplayer-loading\"></div>\n <div class=\"artplayer-notice\">\n <div class=\"artplayer-notice-inner\"></div>\n </div>\n <div class=\"artplayer-setting\">\n <div class=\"artplayer-setting-inner\">\n <div class=\"artplayer-setting-body\"></div>\n <div class=\"artplayer-setting-close\">\xD7</div>\n </div>\n </div>\n <div class=\"artplayer-info\">\n <div class=\"artplayer-info-panel\"></div>\n <div class=\"artplayer-info-close\">[x]</div>\n </div>\n <div class=\"artplayer-pip-header\">\n <div class=\"artplayer-pip-title\"></div>\n <div class=\"artplayer-pip-close\">\xD7</div>\n </div>\n <div class=\"artplayer-contextmenu\"></div>\n </div>\n ";
|
||||||
this.$player = this.$container.querySelector('.artplayer-video-player');
|
this.$player = this.$container.querySelector('.artplayer-video-player');
|
||||||
this.$video = this.$container.querySelector('.artplayer-video');
|
this.$video = this.$container.querySelector('.artplayer-video');
|
||||||
this.$subtitle = this.$container.querySelector('.artplayer-subtitle');
|
this.$subtitle = this.$container.querySelector('.artplayer-subtitle');
|
||||||
@@ -930,16 +930,17 @@
|
|||||||
value: function value(url) {
|
value: function value(url) {
|
||||||
var typeName = type || getExt(url);
|
var typeName = type || getExt(url);
|
||||||
var typeCallback = customType[typeName];
|
var typeCallback = customType[typeName];
|
||||||
|
sleep().then(function () {
|
||||||
if (typeName && typeCallback) {
|
if (typeName && typeCallback) {
|
||||||
art.emit('beforeCustomType', typeName);
|
art.emit('beforeCustomType', typeName);
|
||||||
typeCallback($video, player.returnUrl(url), art);
|
typeCallback($video, player.returnUrl(url), art);
|
||||||
art.emit('afterCustomType', typeName);
|
art.emit('afterCustomType', typeName);
|
||||||
} else {
|
} else {
|
||||||
art.emit('beforeAttachUrl', url);
|
art.emit('beforeAttachUrl', url);
|
||||||
$video.src = player.returnUrl(url);
|
$video.src = player.returnUrl(url);
|
||||||
art.emit('afterAttachUrl', $video.src);
|
art.emit('afterAttachUrl', $video.src);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -967,9 +968,7 @@
|
|||||||
$video.autoplay = option.autoplay;
|
$video.autoplay = option.autoplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep().then(function () {
|
player.attachUrl(option.url);
|
||||||
player.attachUrl(option.url);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function eventInit(art, player) {
|
function eventInit(art, player) {
|
||||||
@@ -4892,18 +4891,16 @@
|
|||||||
var option = art.option,
|
var option = art.option,
|
||||||
$player = art.template.$player;
|
$player = art.template.$player;
|
||||||
var resizeObserver = new ResizeObserver_2(function () {
|
var resizeObserver = new ResizeObserver_2(function () {
|
||||||
sleep().then(function () {
|
if (option.autoSize) {
|
||||||
if (option.autoSize) {
|
if (!art.player.fullscreenState && !art.player.fullscreenWebState && !art.player.pipState) {
|
||||||
if (!art.player.fullscreenState && !art.player.fullscreenWebState && !art.player.pipState) {
|
art.player.autoSize();
|
||||||
art.player.autoSize();
|
} else {
|
||||||
} else {
|
art.player.autoSizeRemove();
|
||||||
art.player.autoSizeRemove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
art.player.aspectRatioReset();
|
art.player.aspectRatioReset();
|
||||||
art.emit('resize', $player);
|
art.emit('resize', $player);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
resizeObserver.observe($player);
|
resizeObserver.observe($player);
|
||||||
events.destroyEvents.push(function () {
|
events.destroyEvents.push(function () {
|
||||||
@@ -4923,29 +4920,33 @@
|
|||||||
/*#__PURE__*/
|
/*#__PURE__*/
|
||||||
function () {
|
function () {
|
||||||
function Events(art) {
|
function Events(art) {
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
classCallCheck(this, Events);
|
classCallCheck(this, Events);
|
||||||
|
|
||||||
this.destroyEvents = [];
|
this.destroyEvents = [];
|
||||||
this.proxy = this.proxy.bind(this);
|
this.proxy = this.proxy.bind(this);
|
||||||
this.hover = this.hover.bind(this);
|
this.hover = this.hover.bind(this);
|
||||||
this.loadImg = this.loadImg.bind(this);
|
this.loadImg = this.loadImg.bind(this);
|
||||||
clickInit(art, this);
|
art.on('firstCanplay', function () {
|
||||||
hoverInit(art, this);
|
clickInit(art, _this);
|
||||||
mousemoveInitInit(art, this);
|
hoverInit(art, _this);
|
||||||
resizeInit(art, this);
|
mousemoveInitInit(art, _this);
|
||||||
doubleClickInit(art, this);
|
resizeInit(art, _this);
|
||||||
|
doubleClickInit(art, _this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createClass(Events, [{
|
createClass(Events, [{
|
||||||
key: "proxy",
|
key: "proxy",
|
||||||
value: function proxy(target, name, callback) {
|
value: function proxy(target, name, callback) {
|
||||||
var _this = this;
|
var _this2 = this;
|
||||||
|
|
||||||
var option = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
var option = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||||
|
|
||||||
if (Array.isArray(name)) {
|
if (Array.isArray(name)) {
|
||||||
name.forEach(function (item) {
|
name.forEach(function (item) {
|
||||||
return _this.proxy(target, item, callback, option);
|
return _this2.proxy(target, item, callback, option);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4964,7 +4965,7 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "loadImg",
|
key: "loadImg",
|
||||||
value: function loadImg(img) {
|
value: function loadImg(img) {
|
||||||
var _this2 = this;
|
var _this3 = this;
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
var image;
|
var image;
|
||||||
@@ -4982,11 +4983,11 @@
|
|||||||
return resolve(image);
|
return resolve(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
_this2.proxy(image, 'load', function () {
|
_this3.proxy(image, 'load', function () {
|
||||||
return resolve(image);
|
return resolve(image);
|
||||||
});
|
});
|
||||||
|
|
||||||
_this2.proxy(image, 'error', function () {
|
_this3.proxy(image, 'error', function () {
|
||||||
return reject(image);
|
return reject(image);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -5326,25 +5327,21 @@
|
|||||||
/*#__PURE__*/
|
/*#__PURE__*/
|
||||||
function () {
|
function () {
|
||||||
function Storage(art) {
|
function Storage(art) {
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
classCallCheck(this, Storage);
|
classCallCheck(this, Storage);
|
||||||
|
|
||||||
this.art = art;
|
this.art = art;
|
||||||
this.storageName = 'artplayer_settings';
|
this.storageName = 'artplayer_settings';
|
||||||
sleep().then(function () {
|
this.init();
|
||||||
_this.init();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createClass(Storage, [{
|
createClass(Storage, [{
|
||||||
key: "init",
|
key: "init",
|
||||||
value: function init() {
|
value: function init() {
|
||||||
var player = this.art.player;
|
var option = this.art.option;
|
||||||
var volume = this.get('volume');
|
var volume = this.get('volume');
|
||||||
|
|
||||||
if (volume) {
|
if (volume) {
|
||||||
player.volume = volume;
|
option.volume = volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"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/tiny-emitter/index.js","../../../packages/artplayer/node_modules/option-validator/dist/option-validator.js","../../../packages/artplayer/node_modules/deepmerge/dist/es.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/error.js","../../../packages/artplayer/src/utils/dom.js","../../../packages/artplayer/src/utils/subtitle.js","../../../packages/artplayer/src/utils/index.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/src/whitelist.js","../../../packages/artplayer/src/template.js","../../../packages/artplayer/src/i18n.js","../../../packages/artplayer/src/player/attachUrlMix.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/switchQualityMix.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/loadedMix.js","../../../packages/artplayer/src/player/playedMix.js","../../../packages/artplayer/src/player/autoSizeMix.js","../../../packages/artplayer/src/player/flipMix.js","../../../packages/artplayer/src/player/index.js","../../../packages/artplayer/src/mse.js","../../../packages/artplayer/src/utils/component.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/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.jLine 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/tiny-emitter/index.js","../../../packages/artplayer/node_modules/option-validator/dist/option-validator.js","../../../packages/artplayer/node_modules/deepmerge/dist/es.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/error.js","../../../packages/artplayer/src/utils/dom.js","../../../packages/artplayer/src/utils/subtitle.js","../../../packages/artplayer/src/utils/index.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/src/whitelist.js","../../../packages/artplayer/src/template.js","../../../packages/artplayer/src/i18n.js","../../../packages/artplayer/src/player/attachUrlMix.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/switchQualityMix.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/loadedMix.js","../../../packages/artplayer/src/player/playedMix.js","../../../packages/artplayer/src/player/autoSizeMix.js","../../../packages/artplayer/src/player/flipMix.js","../../../packages/artplayer/src/player/index.js","../../../packages/artplayer/src/mse.js","../../../packages/artplayer/src/utils/component.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/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.jLine truncated
|
||||||
@@ -10,11 +10,13 @@ export default class Events {
|
|||||||
this.proxy = this.proxy.bind(this);
|
this.proxy = this.proxy.bind(this);
|
||||||
this.hover = this.hover.bind(this);
|
this.hover = this.hover.bind(this);
|
||||||
this.loadImg = this.loadImg.bind(this);
|
this.loadImg = this.loadImg.bind(this);
|
||||||
clickInit(art, this);
|
art.on('firstCanplay', () => {
|
||||||
hoverInit(art, this);
|
clickInit(art, this);
|
||||||
mousemoveInit(art, this);
|
hoverInit(art, this);
|
||||||
resizeInit(art, this);
|
mousemoveInit(art, this);
|
||||||
doubleClickInit(art, this);
|
resizeInit(art, this);
|
||||||
|
doubleClickInit(art, this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy(target, name, callback, option = {}) {
|
proxy(target, name, callback, option = {}) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { ResizeObserver } from 'resize-observer';
|
import { ResizeObserver } from 'resize-observer';
|
||||||
import { sleep } from '../utils';
|
|
||||||
|
|
||||||
export default function resizeInit(art, events) {
|
export default function resizeInit(art, events) {
|
||||||
const {
|
const {
|
||||||
@@ -7,17 +6,15 @@ export default function resizeInit(art, events) {
|
|||||||
template: { $player },
|
template: { $player },
|
||||||
} = art;
|
} = art;
|
||||||
const resizeObserver = new ResizeObserver(() => {
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
sleep().then(() => {
|
if (option.autoSize) {
|
||||||
if (option.autoSize) {
|
if (!art.player.fullscreenState && !art.player.fullscreenWebState && !art.player.pipState) {
|
||||||
if (!art.player.fullscreenState && !art.player.fullscreenWebState && !art.player.pipState) {
|
art.player.autoSize();
|
||||||
art.player.autoSize();
|
} else {
|
||||||
} else {
|
art.player.autoSizeRemove();
|
||||||
art.player.autoSizeRemove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
art.player.aspectRatioReset();
|
}
|
||||||
art.emit('resize', $player);
|
art.player.aspectRatioReset();
|
||||||
});
|
art.emit('resize', $player);
|
||||||
});
|
});
|
||||||
resizeObserver.observe($player);
|
resizeObserver.observe($player);
|
||||||
events.destroyEvents.push(() => {
|
events.destroyEvents.push(() => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getExt } from '../utils';
|
import { getExt, sleep } from '../utils';
|
||||||
|
|
||||||
export default function attachUrlMix(art, player) {
|
export default function attachUrlMix(art, player) {
|
||||||
const {
|
const {
|
||||||
@@ -15,15 +15,17 @@ export default function attachUrlMix(art, player) {
|
|||||||
value: url => {
|
value: url => {
|
||||||
const typeName = type || getExt(url);
|
const typeName = type || getExt(url);
|
||||||
const typeCallback = customType[typeName];
|
const typeCallback = customType[typeName];
|
||||||
if (typeName && typeCallback) {
|
sleep().then(() => {
|
||||||
art.emit('beforeCustomType', typeName);
|
if (typeName && typeCallback) {
|
||||||
typeCallback($video, player.returnUrl(url), art);
|
art.emit('beforeCustomType', typeName);
|
||||||
art.emit('afterCustomType', typeName);
|
typeCallback($video, player.returnUrl(url), art);
|
||||||
} else {
|
art.emit('afterCustomType', typeName);
|
||||||
art.emit('beforeAttachUrl', url);
|
} else {
|
||||||
$video.src = player.returnUrl(url);
|
art.emit('beforeAttachUrl', url);
|
||||||
art.emit('afterAttachUrl', $video.src);
|
$video.src = player.returnUrl(url);
|
||||||
}
|
art.emit('afterAttachUrl', $video.src);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { clamp, sleep } from '../utils';
|
import { clamp } from '../utils';
|
||||||
|
|
||||||
export default function attrInit(art, player) {
|
export default function attrInit(art, player) {
|
||||||
const {
|
const {
|
||||||
@@ -25,7 +25,5 @@ export default function attrInit(art, player) {
|
|||||||
$video.autoplay = option.autoplay;
|
$video.autoplay = option.autoplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep().then(() => {
|
player.attachUrl(option.url);
|
||||||
player.attachUrl(option.url);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,15 @@
|
|||||||
import { sleep } from './utils';
|
|
||||||
|
|
||||||
export default class Storage {
|
export default class Storage {
|
||||||
constructor(art) {
|
constructor(art) {
|
||||||
this.art = art;
|
this.art = art;
|
||||||
this.storageName = 'artplayer_settings';
|
this.storageName = 'artplayer_settings';
|
||||||
sleep().then(() => {
|
this.init();
|
||||||
this.init();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
const { player } = this.art;
|
const { option } = this.art;
|
||||||
const volume = this.get('volume');
|
const volume = this.get('volume');
|
||||||
if (volume) {
|
if (volume) {
|
||||||
player.volume = volume;
|
option.volume = volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,36 +18,36 @@ export default class Template {
|
|||||||
init() {
|
init() {
|
||||||
this.$container.innerHTML = `
|
this.$container.innerHTML = `
|
||||||
<div class="artplayer-video-player">
|
<div class="artplayer-video-player">
|
||||||
<video data-index="10" class="artplayer-video"></video>
|
<video class="artplayer-video"></video>
|
||||||
<div data-index="20" class="artplayer-subtitle"></div>
|
<div class="artplayer-subtitle"></div>
|
||||||
<div data-index="30" class="artplayer-layers"></div>
|
<div class="artplayer-layers"></div>
|
||||||
<div data-index="40" class="artplayer-mask"></div>
|
<div class="artplayer-mask"></div>
|
||||||
<div data-index="50" class="artplayer-bottom">
|
<div class="artplayer-bottom">
|
||||||
<div class="artplayer-progress"></div>
|
<div class="artplayer-progress"></div>
|
||||||
<div class="artplayer-controls">
|
<div class="artplayer-controls">
|
||||||
<div class="artplayer-controls-left"></div>
|
<div class="artplayer-controls-left"></div>
|
||||||
<div class="artplayer-controls-right"></div>
|
<div class="artplayer-controls-right"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-index="60" class="artplayer-loading"></div>
|
<div class="artplayer-loading"></div>
|
||||||
<div data-index="70" class="artplayer-notice">
|
<div class="artplayer-notice">
|
||||||
<div class="artplayer-notice-inner"></div>
|
<div class="artplayer-notice-inner"></div>
|
||||||
</div>
|
</div>
|
||||||
<div data-index="80" class="artplayer-setting">
|
<div class="artplayer-setting">
|
||||||
<div class="artplayer-setting-inner">
|
<div class="artplayer-setting-inner">
|
||||||
<div class="artplayer-setting-body"></div>
|
<div class="artplayer-setting-body"></div>
|
||||||
<div class="artplayer-setting-close">×</div>
|
<div class="artplayer-setting-close">×</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-index="90" class="artplayer-info">
|
<div class="artplayer-info">
|
||||||
<div class="artplayer-info-panel"></div>
|
<div class="artplayer-info-panel"></div>
|
||||||
<div class="artplayer-info-close">[x]</div>
|
<div class="artplayer-info-close">[x]</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-index="100" class="artplayer-pip-header">
|
<div class="artplayer-pip-header">
|
||||||
<div class="artplayer-pip-title"></div>
|
<div class="artplayer-pip-title"></div>
|
||||||
<div class="artplayer-pip-close">×</div>
|
<div class="artplayer-pip-close">×</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-index="110" class="artplayer-contextmenu"></div>
|
<div class="artplayer-contextmenu"></div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
this.$player = this.$container.querySelector('.artplayer-video-player');
|
this.$player = this.$container.querySelector('.artplayer-video-player');
|
||||||
|
|||||||
Reference in new issue
Block a user