Files
ArtPlayer/docs/compiled/artplayer-plugin-chapter.legacy.js
T
2025-04-20 10:12:14 +08:00

8 lines
6.8 KiB
JavaScript

/*!
* artplayer-plugin-chapter.js v1.0.1
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2025 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,a,n,o,i,l){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},p="function"==typeof d[a]&&d[a],s=p.i||{},u=p.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!u[t]){if(!e[t]){if(n[t])return n[t];var o="function"==typeof d[a]&&d[a];if(!r&&o)return o(t,!0);if(p)return p(t,!0);if(c&&"string"==typeof t)return c(t);var i=Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}s.resolve=function(r){var a=e[t][1][r];return null!=a?a:r},s.cache={};var l=u[t]=new f.Module(t);e[t][0].call(l.exports,s,l,l.exports,d)}return u[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.require=c,this.exports={}},f.modules=e,f.cache=u,f.parent=p,f.distDir=void 0,f.publicUrl=void 0,f.devServer=void 0,f.i=s,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return d[a]}}),d[a]=f;for(var h=0;h<t.length;h++)f(t[h]);if(r){var g=f(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({"9rqDr":[function(e,t,r,a){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",function(){return l});var o=e("bundle-text:./style.less"),i=n.interopDefault(o);function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=t.template.$player,a=t.constructor.utils,n=a.setStyle,o=a.append,i=a.clamp,l=a.query,d=a.isMobile,p=a.addClass,s=a.removeClass,u=null,c=[],f=t.query(".art-control-progress"),h=t.query(".art-control-progress-inner"),g=o(h,'<div class="art-chapters"></div>'),y=o(h,'<div class="art-chapter-title"></div>');function v(e){var t=e.$chapter,r=e.width,a=t.dataset.title.trim();if(a){n(y,"display","flex"),y.innerText=a;var o=y.clientWidth;r<=o/2?n(y,"left",0):r>h.clientWidth-o/2?n(y,"left","".concat(h.clientWidth-o,"px")):n(y,"left","".concat(r-o/2,"px"))}else n(y,"display","none")}function m(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if((c=[],g.innerText="",s(r,"artplayer-plugin-chapter"),Array.isArray(e)&&e.length)&&t.duration){e=e.sort(function(e,t){return e.start-t.start});for(var a=0;a<e.length;a++){var n=e[a],d=e[a+1];if(n.end===1/0&&(n.end=t.duration),"number"!=typeof n.start||"number"!=typeof n.end||"string"!=typeof n.title)throw Error("Illegal chapter data type");if(n.start<0||n.end>t.duration||n.start>=n.end||d&&n.end>d.start)throw Error("Illegal chapter time point")}e[0].start>0&&e.unshift({start:0,end:e[0].start,title:""}),e[e.length-1].end<t.duration&&e.push({start:e[e.length-1].end,end:t.duration,title:""});for(var u=0;u<e.length-1;u++)e[u].end!==e[u+1].start&&e.splice(u+1,0,{start:e[u].end,end:e[u+1].start,title:""});c=e.map(function(e){var r=o(g,'\n <div class="art-chapter">\n<div class="art-chapter-inner">\n<div class="art-progress-hover"></div>\n<div class="art-progress-loaded"></div>\n<div class="art-progress-played"></div>\n</div>\n</div>\n '),a=i(e.start,0,t.duration),n=i(e.end,0,t.duration),d=n-a,p=d/t.duration;return r.dataset.start=a,r.dataset.end=n,r.dataset.duration=d,r.dataset.title=e.title.trim(),r.style.width="".concat(100*p,"%"),{$chapter:r,$hover:l(".art-progress-hover",r),$loaded:l(".art-progress-loaded",r),$played:l(".art-progress-played",r)}}),p(r,"artplayer-plugin-chapter"),t.emit("setBar","loaded",t.loaded||0)}}return t.on("setBar",function(e,r,a){if(c.length)for(var o=0;o<c.length;o++){var i=c[o],l=i.$chapter,p=i.$loaded,s=i.$played,f={hover:i.$hover,loaded:p,played:s}[e];if(!f)return;var h=g.clientWidth*r,m=t.duration*r,b=parseFloat(l.dataset.duration),x=parseFloat(l.dataset.start),w=parseFloat(l.dataset.end);if(m<x&&n(f,"width",0),m>w&&n(f,"width","100%"),m>=x&&m<=w){var j=(m-x)/b;n(f,"width","".concat(100*j,"%")),d?"played"===e&&a&&(v({$chapter:l,width:h}),clearTimeout(u),u=setTimeout(function(){n(y,"display","none")},500)):"hover"===e&&v({$chapter:l,width:h})}}}),d||t.proxy(f,"mouseleave",function(){c.length&&n(y,"display","none")}),t.once("video:loadedmetadata",function(){return m(e.chapters)}),{name:"artplayerPluginChapter",update:function(e){return m(e.chapters)}}}}if("undefined"!=typeof document){var d="artplayer-plugin-chapter",p=document.getElementById(d);p||((p=document.createElement("style")).id=d,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){document.head.appendChild(p)}):(document.head||document.documentElement).appendChild(p)),p.textContent=i.default}"undefined"!=typeof window&&(window.artplayerPluginChapter=l)},{"bundle-text:./style.less":"4jhrf","@parcel/transformer-js/src/esmodule-helpers.js":"iWrD0"}],"4jhrf":[function(e,t,r,a){t.exports=".artplayer-plugin-chapter .art-control-progress-inner{background-color:transparent!important;height:100%!important}.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-hover,.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-loaded,.artplayer-plugin-chapter .art-control-progress-inner>.art-progress-played{display:none!important}.artplayer-plugin-chapter .art-control-thumbnails{bottom:calc(var(--art-bottom-gap) + 64px)!important}.artplayer-plugin-chapter .art-chapters{z-index:0;align-items:center;gap:4px;height:100%;display:flex;position:absolute;top:0;bottom:0;left:0;right:0;transform:scaleY(1.25)}.artplayer-plugin-chapter .art-chapters .art-chapter{align-items:center;height:100%;display:flex}.artplayer-plugin-chapter .art-chapters .art-chapter .art-chapter-inner{cursor:pointer;width:100%;height:50%;transition:height var(--art-transition-duration)ease;background-color:var(--art-progress-color);border-radius:10px;position:relative;overflow:hidden}.artplayer-plugin-chapter .art-chapters .art-chapter:hover .art-chapter-inner{height:100%}.artplayer-plugin-chapter .art-chapter-title{z-index:70;border-radius:var(--art-border-radius);white-space:nowrap;background-color:var(--art-tip-background);padding:3px 5px;font-size:14px;line-height:1;display:none;position:absolute;top:-50px;left:0}"},{}],iWrD0:[function(e,t,r,a){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}]},["9rqDr"],"9rqDr","parcelRequire4dc0",{});