mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 16:11:20 -08:00
return play() result
This commit is contained in:
1 parent
3f21ce9223
commit
2c83ea4760
10 files changed
+52
-18
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import screenfull from 'screenfull';
|
||||
import { addClass, removeClass, def } from '../utils';
|
||||
import { addClass, removeClass, def, get } from '../utils';
|
||||
|
||||
const nativeScreenfull = (art, player) => {
|
||||
const { $player } = art.template;
|
||||
@@ -74,7 +74,7 @@ export default function fullscreenMix(art, player) {
|
||||
}
|
||||
|
||||
// 异步设置
|
||||
def(art, 'fullscreen', Object.getOwnPropertyDescriptor(player, 'fullscreen'));
|
||||
def(art, 'fullscreen', get(player, 'fullscreen'));
|
||||
});
|
||||
|
||||
def(player, 'fullscreenToggle', {
|
||||
|
||||
@@ -9,9 +9,10 @@ export default function pauseMix(art, player) {
|
||||
|
||||
def(player, 'pause', {
|
||||
value() {
|
||||
$video.pause();
|
||||
const result = $video.pause();
|
||||
notice.show = i18n.get('Pause');
|
||||
art.emit('pause');
|
||||
return result;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -30,6 +30,8 @@ export default function playMix(art, player) {
|
||||
|
||||
notice.show = i18n.get('Play');
|
||||
art.emit('play');
|
||||
|
||||
return promise;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -8,7 +8,7 @@ export default function urlMix(art, player) {
|
||||
|
||||
def(player, 'url', {
|
||||
get() {
|
||||
return $video.src;
|
||||
return $video.currentSrc;
|
||||
},
|
||||
set(url) {
|
||||
const typeName = option.type || getExt(url);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { errorHandle, query, addClass } from './utils';
|
||||
import { errorHandle, query, addClass, replaceElement } from './utils';
|
||||
|
||||
export default class Template {
|
||||
constructor(art) {
|
||||
@@ -12,11 +12,16 @@ export default class Template {
|
||||
errorHandle(this.$container, `No container element found by ${art.option.container}`);
|
||||
}
|
||||
|
||||
const type = this.$container.tagName.toLowerCase();
|
||||
errorHandle(type === 'div', `Unsupported container element type, only support 'div' but got '${type}'`);
|
||||
|
||||
errorHandle(
|
||||
art.constructor.instances.every((ins) => ins.template.$container !== this.$container),
|
||||
'Cannot mount multiple instances on the same dom element',
|
||||
);
|
||||
|
||||
this.$original = this.$container.cloneNode(true);
|
||||
|
||||
if (art.whitelist.state) {
|
||||
this.desktop();
|
||||
} else {
|
||||
@@ -154,7 +159,7 @@ export default class Template {
|
||||
|
||||
destroy(removeHtml) {
|
||||
if (removeHtml) {
|
||||
this.$container.innerHTML = '';
|
||||
replaceElement(this.$original, this.$container);
|
||||
} else {
|
||||
addClass(this.$player, 'art-destroy');
|
||||
}
|
||||
|
||||
@@ -77,3 +77,8 @@ export function isInViewport(el, offset = 0) {
|
||||
export function includeFromEvent(event, target) {
|
||||
return event.composedPath && event.composedPath().indexOf(target) > -1;
|
||||
}
|
||||
|
||||
export function replaceElement(newChild, oldChild) {
|
||||
oldChild.parentNode.replaceChild(newChild, oldChild);
|
||||
return newChild;
|
||||
}
|
||||
@@ -7,20 +7,24 @@ export function has(obj, name) {
|
||||
return hasOwnProperty.call(obj, name);
|
||||
}
|
||||
|
||||
export function get(obj, name) {
|
||||
return Object.getOwnPropertyDescriptor(obj, name);
|
||||
}
|
||||
|
||||
export function proxyPropertys(target, ...sources) {
|
||||
return sources.reduce((result, source) => {
|
||||
Object.getOwnPropertyNames(source).forEach(key => {
|
||||
Object.getOwnPropertyNames(source).forEach((key) => {
|
||||
errorHandle(!has(result, key), `Target attribute name is duplicated: ${key}`);
|
||||
def(result, key, Object.getOwnPropertyDescriptor(source, key));
|
||||
def(result, key, get(source, key));
|
||||
});
|
||||
return result;
|
||||
}, target);
|
||||
}
|
||||
|
||||
export function mergeDeep(...objects) {
|
||||
const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
|
||||
const isObject = (item) => item && typeof item === 'object' && !Array.isArray(item);
|
||||
return objects.reduce((prev, obj) => {
|
||||
Object.keys(obj).forEach(key => {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
const pVal = prev[key];
|
||||
const oVal = obj[key];
|
||||
if (Array.isArray(pVal) && Array.isArray(oVal)) {
|
||||
|
||||
Reference in new issue
Block a user