mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 13:21:20 -08:00
finish the ads.js
This commit is contained in:
1 parent
6c32895d34
commit
76eea4bfd5
10 files changed
+83
-42
No files matched your search
@@ -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,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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user