finish the ads.js

This commit is contained in:
Harvey committed 2021-12-23 15:43:42 +08:00
1 parent 6c32895d34
commit 76eea4bfd5
10 files changed
+83 -42

No files matched your search

+1 -5
View File
@@ -35,11 +35,7 @@ export default function attrInit(art, player) {
$video.controls = false;
if (option.ads.length) {
art.on('ads:end', () => {
player.url = option.url;
});
} else {
if (option.ads.length === 0) {
player.url = option.url;
}
}
+2
View File
@@ -2,6 +2,7 @@ import urlMix from './urlMix';
import attrInit from './attrInit';
import eventInit from './eventInit';
import exclusiveInit from './exclusiveInit';
import timeupdateInit from './timeupdateInit';
import playMix from './playMix';
import pauseMix from './pauseMix';
import toggleMix from './toggleMix';
@@ -34,6 +35,7 @@ export default class Player {
eventInit(art, this);
attrInit(art, this);
exclusiveInit(art, this);
timeupdateInit(art, this);
playMix(art, this);
pauseMix(art, this);
toggleMix(art, this);
+1 -1
View File
@@ -22,7 +22,7 @@ export default function loopMin(art, player) {
},
});
art.on('video:timeupdate', () => {
art.on('timeupdate', () => {
if (interval.length) {
if (player.currentTime < interval[0] || player.currentTime > interval[1]) {
player.seek = interval[0];
+1 -2
View File
@@ -7,7 +7,6 @@ export default function switchMix(art, player) {
return new Promise((resolve) => {
if (url === player.url) return resolve(url);
URL.revokeObjectURL(player.url);
const { playing } = player;
player.url = url;
art.once('video:canplay', () => {
player.playbackRate = false;
@@ -16,7 +15,7 @@ export default function switchMix(art, player) {
player.autoSize = option.autoSize;
player.currentTime = currentTime;
art.notice.show = '';
if (playing) {
if (player.playing) {
player.play();
}
if (name) {
@@ -0,0 +1,14 @@
export default function timeupdateInit(art, player) {
let timer = null;
(function timeupdate() {
art.emit('timeupdate', player.currentTime || 0);
if (!art.isDestroy) {
timer = window.requestAnimationFrame(timeupdate);
}
})();
art.on('destroy', () => {
window.cancelAnimationFrame(timer);
});
}