forked from the1812/Bilibili-Evolved
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intersection-actions.js
1 lines (1 loc) · 2.2 KB
/
intersection-actions.js
1
!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 s}});var n,o=coreApis.componentApis.video.playerAgent,a=coreApis.componentApis.video.playerLight,i=coreApis.observer,r=coreApis.settings;!function(e){e.Top="视频顶部",e.Medium="视频中间",e.Bottom="视频底部"}(n||(n={}));const s={name:"playerIntersectionActions",author:{name:"FoundTheWOUT",link:"https://github.com/FoundTheWOUT"},tags:[componentsTags.video],entry:async({settings:{options:e},metadata:t})=>{const s=e,{query:{video:p}}=o.playerAgent,c=await p.element(),d=document.getElementById("video-player")??(dq(".player-wrap")||dq(".player-module"));let u,l=!0;function m(e){switch(e){case n.Top:return 1;case n.Medium:return.5;case n.Bottom:return 0;default:return.5}}function y(){u.observe(d)}function g(){u.unobserve(d)}const f=e=>new IntersectionObserver((([e])=>{e.isIntersecting?l||(l=!0,s.pause&&c.paused&&c.play(),s.light&&(0,r.getComponentSettings)("playerAutoLight").enabled&&!s.pause&&!c.paused&&(0,a.lightOff)()):(c.paused||(l=!1),s.pause&&!c.paused&&c.pause(),s.light&&(0,r.getComponentSettings)("playerAutoLight").enabled&&!s.pause&&(0,a.lightOn)())}),{threshold:m(e||s.triggerLocation)});(0,r.addComponentListener)(`${t.name}.triggerLocation`,(e=>{g(),u=f(e),y()})),u=f(),(0,i.videoChange)((async()=>{o.playerAgent.isAutoPlay()&&y(),c.addEventListener("play",y),c.addEventListener("ended",g)}))},displayName:"播放器位置动作",description:{"zh-CN":"设置当播放器移出视图的位置变化时执行的动作."},options:{triggerLocation:{defaultValue:n.Medium,displayName:"触发位置",dropdownEnum:n},pause:{defaultValue:!1,displayName:"自动暂停"},light:{defaultValue:!0,displayName:"自动开灯"}},commitHash:"259797c283aac82bb5ead0c2c214b08a12a37c25"};return t=t.component}()}));