diff --git a/docs/compiled/artplayer-plugin-ads.mjs b/docs/compiled/artplayer-plugin-ads.mjs index 59a19865c..b7f53a3f1 100644 --- a/docs/compiled/artplayer-plugin-ads.mjs +++ b/docs/compiled/artplayer-plugin-ads.mjs @@ -4,251 +4,4 @@ * (c) 2017-2026 Harvey Zhao * Released under the MIT License. */ -const style = ".artplayer-plugin-ads{position:absolute;z-index:150;inset:0;width:100%;height:100%;overflow:hidden;font-size:13px;line-height:1;color:#fff;background-color:#000}.artplayer-plugin-ads .artplayer-plugin-ads-html{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.artplayer-plugin-ads .artplayer-plugin-ads-video{width:100%;height:100%}.artplayer-plugin-ads .artplayer-plugin-ads-timer{display:none;position:absolute;top:10px;right:10px}.artplayer-plugin-ads .artplayer-plugin-ads-timer>div{display:flex;align-items:center;background-color:#00000080;border-radius:15px;margin-left:5px;padding:5px 10px;cursor:pointer}.artplayer-plugin-ads .artplayer-plugin-ads-control{display:none;position:absolute;bottom:10px;right:10px}.artplayer-plugin-ads .artplayer-plugin-ads-control>div{display:flex;align-items:center;background-color:#00000080;border-radius:15px;margin-left:5px;padding:5px 10px;cursor:pointer}.artplayer-plugin-ads .artplayer-plugin-ads-control .art-icon svg{width:20px;height:20px}.artplayer-plugin-ads .artplayer-plugin-ads-loading{display:flex;align-items:center;justify-content:center;position:absolute;inset:0;width:100%;height:100%}"; -function checkVersion(art) { - const { - version, - utils: { errorHandle } - } = art.constructor; - const arr = version.split(".").map(Number); - const major = arr[0]; - const minor = arr[1] / 100; - errorHandle( - major + minor >= 5, - `Artplayer.js@${version} is not compatible the artplayerPluginAds@${artplayerPluginAds.version}. Please update it to version Artplayer.js@5.x.x` - ); -} -function artplayerPluginAds(option) { - return (art) => { - checkVersion(art); - const { - template: { $player }, - icons: { volume, volumeClose, fullscreenOn, fullscreenOff, loading }, - constructor: { - validator, - utils: { query, append, setStyle } - } - } = art; - option = validator( - { - html: "", - video: "", - url: "", - playDuration: 5, - totalDuration: 10, - muted: false, - i18n: { - close: "关闭广告", - countdown: "%s秒", - detail: "查看详情", - canBeClosed: "%s秒后可关闭广告" - }, - ...option - }, - { - html: "?string", - video: "?string", - url: "?string", - playDuration: "number", - totalDuration: "number", - muted: "?boolean", - i18n: { - close: "string", - countdown: "string", - detail: "string", - canBeClosed: "string" - } - } - ); - let $ads = null; - let $timer = null; - let $close = null; - let $countdown = null; - let $control = null; - let $loading = null; - let time = 0; - let timer = null; - let isEnd = false; - let isInit = false; - let isCanClose = false; - function getI18n(val, str) { - return str.replace("%s", val); - } - function skip() { - isEnd = true; - art.play(); - if (option.video) - $ads.pause(); - setStyle(art.template.$ads, "display", "none"); - art.emit("artplayerPluginAds:skip", option); - } - function play() { - if (isEnd) - return; - timer = setTimeout(() => { - time += 1; - const playDuration = option.playDuration - time; - if (playDuration >= 1) { - $close.innerHTML = getI18n(playDuration, option.i18n.canBeClosed); - } else { - $close.innerHTML = option.i18n.close; - if (!isCanClose) { - isCanClose = true; - } - } - $countdown.innerHTML = getI18n(option.totalDuration - time, option.i18n.countdown); - if (time >= option.totalDuration) { - skip(); - } else { - play(); - } - }, 1e3); - } - function pause() { - if (isEnd) - return; - clearTimeout(timer); - } - function show() { - art.template.$ads = append($player, '
'); - $ads = append( - art.template.$ads, - option.video ? `` : `