Bilibili-Evolved/registry/dist/components/video/player/intersection-actions.js
2022-09-03 11:00:11 +08:00

1 line
2.3 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/player/intersection-actions"]=t():e["video/player/intersection-actions"]=t()}(self,(function(){return function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{component:function(){return p}});var n,o=coreApis.componentApis.video.playerAgent,i=coreApis.componentApis.video.playerLight,r=coreApis.observer,a=coreApis.settings,s=coreApis.utils.urls;!function(e){e.Top="视频顶部",e.Medium="视频中间",e.Bottom="视频底部"}(n||(n={}));const p={name:"playerIntersectionActions",author:{name:"FoundTheWOUT",link:"https://github.com/FoundTheWOUT"},tags:[componentsTags.video],urlInclude:s.allVideoUrls,entry:async e=>{let{settings:{options:t},metadata:s}=e;const p=t;Promise.resolve().then((async()=>{const{query:{video:e}}=o.playerAgent,t=await e.element(),u=document.getElementById("video-player")??(dq(".player-wrap")||dq(".player-module"));let d,c=!0;function l(e){switch(e){case n.Top:return 1;case n.Medium:return.5;case n.Bottom:return 0;default:return.5}}function m(){d.observe(u)}function y(){d.unobserve(u)}const g=e=>new IntersectionObserver((e=>{let[n]=e;n.isIntersecting?c||(c=!0,p.pause&&t.paused&&t.play(),p.light&&(0,a.getComponentSettings)("playerAutoLight").enabled&&!p.pause&&!t.paused&&(0,i.lightOff)()):(t.paused||(c=!1),p.pause&&!t.paused&&t.pause(),p.light&&(0,a.getComponentSettings)("playerAutoLight").enabled&&!p.pause&&(0,i.lightOn)())}),{threshold:l(e||p.triggerLocation)});(0,a.addComponentListener)(`${s.name}.triggerLocation`,(e=>{y(),d=g(e),m()})),d=g(),(0,r.videoChange)((async()=>{o.playerAgent.isAutoPlay()&&m(),t.addEventListener("play",m),t.addEventListener("ended",y)}))}))},displayName:"播放器位置动作",description:{"zh-CN":"设置当播放器移出视图的位置变化时执行的动作."},options:{triggerLocation:{defaultValue:n.Medium,displayName:"触发位置",dropdownEnum:n},pause:{defaultValue:!1,displayName:"自动暂停"},light:{defaultValue:!0,displayName:"自动开灯"}},commitHash:"651309f7b92c7340876f05d69ea349d173e67345",coreVersion:"2.4.0"};return t=t.component}()}));