mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:51:20 -08:00
压缩字符
This commit is contained in:
1 parent
7ff61b4660
commit
0cf455ced3
27 files changed
+171
-239
No files matched your search
@@ -1,9 +1,7 @@
|
||||
import { setStyle, addClass, removeClass, hasClass, def } from '../utils';
|
||||
|
||||
export default function resizeMix(art, player) {
|
||||
const {
|
||||
template: { $container, $player, $video },
|
||||
} = art;
|
||||
const { $container, $player, $video } = art.template;
|
||||
|
||||
def(player, 'autoSize', {
|
||||
get() {
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function eventInit(art, player) {
|
||||
player.toggle = true;
|
||||
});
|
||||
|
||||
config.video.events.forEach(eventName => {
|
||||
config.events.forEach(eventName => {
|
||||
proxy($video, eventName, event => {
|
||||
art.emit(`video:${event.type}`, event);
|
||||
});
|
||||
@@ -72,7 +72,7 @@ export default function eventInit(art, player) {
|
||||
addClass($player, 'art-error');
|
||||
sleep(1000).then(() => {
|
||||
notice.show = i18n.get('Video load failed');
|
||||
art.destroy();
|
||||
art.destroy(false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { errorHandle, def } from '../utils';
|
||||
|
||||
export default function flipMix(art, player) {
|
||||
const { $player } = art.template;
|
||||
def(player, 'flip', {
|
||||
get() {
|
||||
return art.template.$player.dataset.flip;
|
||||
return $player.dataset.flip;
|
||||
},
|
||||
set(flip) {
|
||||
if (flip) {
|
||||
const flipList = ['normal', 'horizontal', 'vertical'];
|
||||
errorHandle(flipList.includes(flip), `'flip' only accept ${flipList.toString()} as parameters`);
|
||||
art.template.$player.dataset.flip = flip;
|
||||
$player.dataset.flip = flip;
|
||||
art.emit('flipChange', flip);
|
||||
} else {
|
||||
delete art.template.$player.dataset.flip;
|
||||
delete $player.dataset.flip;
|
||||
art.emit('flipRemove');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,8 +2,9 @@ import { def } from '../utils';
|
||||
|
||||
export default function seekMix(art, player) {
|
||||
const { $video } = art.template;
|
||||
|
||||
def(player, 'loaded', {
|
||||
get: () => ($video.buffered.length ? $video.buffered.end($video.buffered.length - 1) / $video.duration : 0),
|
||||
get: () => player.loadedTime / $video.duration,
|
||||
});
|
||||
|
||||
def(player, 'loadedTime', {
|
||||
|
||||
@@ -119,7 +119,7 @@ function customPip(art, player) {
|
||||
player.aspectRatio = false;
|
||||
player.playbackRate = false;
|
||||
art.emit('pipChange', true);
|
||||
} else {
|
||||
} else if (player.pip) {
|
||||
$player.style.cssText = cacheStyle;
|
||||
removeClass($player, 'art-pip');
|
||||
setStyle($player, 'top', null);
|
||||
|
||||
@@ -4,6 +4,7 @@ export default function playMix(art, player) {
|
||||
const {
|
||||
i18n,
|
||||
notice,
|
||||
constructor: { instances },
|
||||
option: { mutex },
|
||||
template: { $video },
|
||||
} = art;
|
||||
@@ -12,7 +13,7 @@ export default function playMix(art, player) {
|
||||
set(value) {
|
||||
if (value) {
|
||||
const promise = $video.play();
|
||||
if (promise !== undefined) {
|
||||
if (promise.then) {
|
||||
promise.then().catch(err => {
|
||||
notice.show = err;
|
||||
throw err;
|
||||
@@ -20,7 +21,7 @@ export default function playMix(art, player) {
|
||||
}
|
||||
|
||||
if (mutex) {
|
||||
art.constructor.instances
|
||||
instances
|
||||
.filter(item => item !== art)
|
||||
.forEach(item => {
|
||||
item.player.pause = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { def } from '../utils';
|
||||
|
||||
export default function seekMix(art, player) {
|
||||
export default function playedMix(art, player) {
|
||||
def(player, 'played', {
|
||||
get: () => art.template.$video.currentTime / art.template.$video.duration,
|
||||
get: () => player.currentTime / player.duration,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user