mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-20 20:21:20 -08:00
update mobile demo
This commit is contained in:
1 parent
8d04f11048
commit
d148e7d9e5
3 files changed
+55
-59
No files matched your search
@@ -185,6 +185,7 @@ function artplayerPluginAds(option) {
|
||||
let time = 0;
|
||||
let timer = null;
|
||||
let isEnd = false;
|
||||
let isInit = false;
|
||||
function getI18n(val, str) {
|
||||
return str.replace("%s", val);
|
||||
}
|
||||
@@ -214,7 +215,7 @@ function artplayerPluginAds(option) {
|
||||
if (isEnd) return;
|
||||
clearTimeout(timer);
|
||||
}
|
||||
function init() {
|
||||
function show() {
|
||||
art.template.$ads = append($player, '<div class="artplayer-plugin-ads"></div>');
|
||||
$ads = append(art.template.$ads, option.video ? `<video class="artplayer-plugin-ads-video" src="${option.video}" loop playsInline></video>` : `<div class="artplayer-plugin-ads-html">${option.html}</div>`);
|
||||
$loading = append(art.template.$ads, '<div class="artplayer-plugin-ads-loading"></div>');
|
||||
@@ -271,38 +272,34 @@ function artplayerPluginAds(option) {
|
||||
art.emit("artplayerPluginAds:click", option);
|
||||
});
|
||||
}
|
||||
art.on("ready", ()=>{
|
||||
console.log(0);
|
||||
art.once("play", ()=>{
|
||||
console.log(1);
|
||||
init();
|
||||
console.log(2);
|
||||
art.pause();
|
||||
console.log(3);
|
||||
if (option.video) {
|
||||
console.log(4);
|
||||
art.proxy($ads, "error", skip);
|
||||
art.proxy($ads, "loadedmetadata", ()=>{
|
||||
console.log(5);
|
||||
play();
|
||||
console.log(6);
|
||||
$ads.play();
|
||||
console.log(7);
|
||||
setStyle($timer, "display", "flex");
|
||||
setStyle($control, "display", "flex");
|
||||
setStyle($loading, "display", "none");
|
||||
});
|
||||
} else {
|
||||
function init() {
|
||||
if (isInit) return;
|
||||
isInit = true;
|
||||
show();
|
||||
art.pause();
|
||||
if (option.video) {
|
||||
art.proxy($ads, "error", skip);
|
||||
art.proxy($ads, "loadedmetadata", ()=>{
|
||||
play();
|
||||
$ads.play();
|
||||
setStyle($timer, "display", "flex");
|
||||
setStyle($control, "display", "flex");
|
||||
setStyle($loading, "display", "none");
|
||||
}
|
||||
art.proxy(document, "visibilitychange", ()=>{
|
||||
if (document.hidden) pause();
|
||||
else play();
|
||||
});
|
||||
} else {
|
||||
play();
|
||||
setStyle($timer, "display", "flex");
|
||||
setStyle($control, "display", "flex");
|
||||
setStyle($loading, "display", "none");
|
||||
}
|
||||
art.proxy(document, "visibilitychange", ()=>{
|
||||
if (document.hidden) pause();
|
||||
else play();
|
||||
});
|
||||
}
|
||||
art.on("ready", ()=>{
|
||||
art.once("play", init);
|
||||
art.once("video:playing", init);
|
||||
});
|
||||
return {
|
||||
name: "artplayerPluginAds",
|
||||
|
||||
Reference in new issue
Block a user