ogplayer 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -26
- package/dist/ogplayer.global.js +1 -1
- package/dist/ogplayer.js +1 -1
- package/package.json +16 -3
package/README.md
CHANGED
|
@@ -7,24 +7,20 @@ standards.
|
|
|
7
7
|
|
|
8
8
|
> OGPlayer is a product of Inverse DOO.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Under the hood
|
|
11
11
|
|
|
12
|
-
- **Language:** TypeScript — typed like Kotlin/Swift, compiles to JavaScript.
|
|
13
12
|
- **Playback:** the browser's `<video>` element plays the media. HLS streams
|
|
14
13
|
are fed to it through [hls.js](https://github.com/video-dev/hls.js) using
|
|
15
|
-
Media Source Extensions
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
break the player (and vice versa). The web parallel of "Compose-only /
|
|
23
|
-
SwiftUI-only": one modern UI technology, no legacy widgets.
|
|
14
|
+
Media Source Extensions; Safari plays HLS natively so hls.js steps aside
|
|
15
|
+
there. Progressive MP4 plays directly.
|
|
16
|
+
- **UI:** a **custom element** `<og-player>` that works identically in plain
|
|
17
|
+
HTML, React, Vue and Angular, with all styles isolated in a shadow DOM so
|
|
18
|
+
host-page CSS can't break the player (and vice versa).
|
|
19
|
+
- **Types:** written in TypeScript — full type declarations ship with the
|
|
20
|
+
package.
|
|
24
21
|
- **License:** the same `OGP1.…` offline keys as Android/iOS, verified with
|
|
25
|
-
the browser's built-in WebCrypto
|
|
26
|
-
|
|
27
|
-
the page **hostname**.
|
|
22
|
+
the browser's built-in WebCrypto — one license unlocks all three
|
|
23
|
+
platforms. On the web, `apps` patterns bind to the page **hostname**.
|
|
28
24
|
|
|
29
25
|
## Quick start
|
|
30
26
|
|
|
@@ -95,18 +91,6 @@ Evergreen Chrome / Edge / Firefox / Safari 16+ (desktop & mobile). Every API
|
|
|
95
91
|
used (MSE, custom elements, shadow DOM, WebCrypto, Fullscreen) has been
|
|
96
92
|
baseline for years; no polyfills.
|
|
97
93
|
|
|
98
|
-
## Development
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
npm install
|
|
102
|
-
npm run build # dist/ogplayer.js (ESM) + dist/ogplayer.global.js (CDN) + types
|
|
103
|
-
npm test # node --test (license crypto, matchers)
|
|
104
|
-
npm run dev # rebuild + serve demos at http://localhost:8123/demo/
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
`scripts/smoke.mjs` runs the demo page in headless Chromium (playwright)
|
|
108
|
-
and asserts the engine reaches READY with zero page errors.
|
|
109
|
-
|
|
110
94
|
## Feature parity vs Android (reference)
|
|
111
95
|
|
|
112
96
|
| Feature | Android | iOS | Web |
|
package/dist/ogplayer.global.js
CHANGED
|
@@ -282,4 +282,4 @@ Schedule: ${l.map(m=>Ue(m))} pos: ${this.timelinePos}`),c.length&&this.log(`Remo
|
|
|
282
282
|
.fs .ratings .age, .fs .ratings .desc { width:36px; height:36px; font-size:16px; }
|
|
283
283
|
`}buildButtons(){let e=this.q(".buttons");e.innerHTML="";let t=(r,a,o)=>{let l=document.createElement("button");return l.className=`bbtn b-${r}`,l.innerHTML=this.glyph(a,this.dimE.iconSize),l.addEventListener("click",d=>{d.stopPropagation(),o(),this.armAutoHide()}),e.appendChild(l),l};this.cfg.showVolumeButton&&t("volume","volumeOn",()=>this.toggleMenu("volume")),this.cfg.showSpeedButton&&t("speed","speed",()=>this.toggleMenu("speed")),this.cfg.showQualityButton&&t("quality","quality",()=>this.toggleMenu("quality")),this.cfg.showAudioTrackButton&&t("audio","audioTrack",()=>this.toggleMenu("audio")),this.cfg.showSubtitleButton&&t("subs","subtitles",()=>this.toggleMenu("subs")),this.cfg.showFullscreenButton&&t("fs","fullscreenEnter",()=>this.toggleFullscreen());let s=this.q(".seekback"),i=this.q(".seekfwd");s.hidden=i.hidden=!this.cfg.showSeekButtons,this.q(".seekback .seeknum").textContent=String(Math.round((this.playerRef?.seekBackwardIncrementMs??1e4)/1e3)),this.q(".seekfwd .seeknum").textContent=String(Math.round((this.playerRef?.seekForwardIncrementMs??1e4)/1e3)),this.q(".scrub").hidden=!this.cfg.showProgressBar,this.q(".time").hidden=!this.cfg.showTimeLabels}buildTopEnd(){let e=this.q(".topend");e.innerHTML="",this.cfg.customActions.slice(0,8).forEach((t,s)=>{let i=document.createElement("button");i.className="abtn",i.setAttribute("aria-label",t.accessibilityLabel??`Custom action ${s+1}`),i.innerHTML=t.svg;let r=i.querySelector("svg");r&&(r.style.color=this.col.foreground,r.setAttribute("fill","currentColor")),i.addEventListener("click",a=>{a.stopPropagation(),t.onClick(),this.armAutoHide()}),e.appendChild(i)})}toggleMenu(e){if(this.openMenu===e){this.closeMenu();return}this.openMenu=e;let t=this.q(".menu");t.hidden=!1,t.classList.toggle("narrow",e==="volume"),t.innerHTML="";let s=this.playerRef,i=this.col,r=(a,o,l,d)=>{let c=document.createElement("div");c.className="mitem",c.innerHTML=`<span class="mcheck">${o?wt("check",18,i.adAccent):""}</span>
|
|
284
284
|
<span>${a}</span>${l?`<span class="msub">${l}</span>`:""}`,c.addEventListener("click",h=>{h.stopPropagation(),d(),this.closeMenu(),this.armAutoHide()}),t.appendChild(c)};if(e==="volume"){let a=document.createElement("div");a.className="mitem vol";let o=()=>this.glyph(s.isMuted||s.volume===0?"volumeMute":"volumeOn",22);a.innerHTML=`<button class="mmute" aria-label="Mute">${o()}</button>
|
|
285
|
-
<input type="range" min="0" max="100" value="${s.isMuted?0:Math.round(s.volume*100)}">`;let l=a.querySelector("input"),d=a.querySelector(".mmute"),c=()=>{d.innerHTML=o(),this.syncButtons()};l.addEventListener("input",()=>{s.volume=Number(l.value)/100,s.isMuted&&Number(l.value)>0&&(s.isMuted=!1),c()}),l.addEventListener("click",h=>h.stopPropagation()),d.addEventListener("click",h=>{h.stopPropagation(),s.isMuted=!s.isMuted,l.value=String(s.isMuted?0:Math.round(s.volume*100)),c()}),t.appendChild(a)}else if(e==="speed")nm.forEach(a=>r(a===1?"Normal":`${a}\xD7`,s.playbackSpeed===a,null,()=>{s.playbackSpeed=a}));else if(e==="quality"){let a=s.videoQualities;a.length===0&&r("Auto",!0,"adaptive",()=>{}),a.forEach(o=>r(o.id==="auto"?"Auto":`${o.height}p`,o.isSelected,o.id==="auto"?"adaptive":`${Math.round(o.bitrate/1e3)} kbps`,()=>s.selectVideoQuality(o.id)))}else if(e==="audio")s.audioTracks.forEach(a=>r(a.label,a.isSelected,a.language||null,()=>s.selectAudioTrack(a.id))),s.audioTracks.length===0&&r("Default",!0,null,()=>{});else if(e==="subs"){let a=s.textTracks;r("Off",!a.some(o=>o.isSelected),null,()=>s.selectTextTrack(null)),a.forEach(o=>r(o.label,o.isSelected,o.language||null,()=>s.selectTextTrack(o.id)))}}closeMenu(){this.openMenu=null,this.q(".menu").hidden=!0}bind(){let e=this.playerRef,t=this.q(".stage"),s=d=>{if(!d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub,.livechip")){if(this.openMenu){this.closeMenu();return}this.controlsVisible?this.hideControls():this.showControls()}};t.addEventListener("click",s),this.cfg.doubleClickToSeek&&t.addEventListener("dblclick",d=>{if(d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub"))return;let c=t.getBoundingClientRect();d.clientX-c.left<c.width/2?e.seekBackward():e.seekForward()}),this.q(".playpause").addEventListener("click",d=>{d.stopPropagation(),e.isPlaying?e.pause():e.play(),this.armAutoHide()}),this.q(".seekback").addEventListener("click",d=>{d.stopPropagation(),e.seekBackward(),this.armAutoHide()}),this.q(".seekfwd").addEventListener("click",d=>{d.stopPropagation(),e.seekForward(),this.armAutoHide()}),this.q(".livechip").addEventListener("click",d=>{d.stopPropagation(),e.seekToLiveEdge(),this.armAutoHide()}),this.q(".adtransport").addEventListener("click",d=>{d.stopPropagation(),e.adPaused?e.play():e.pause()}),this.bindScrub();let i={onStateChanged:d=>this.onState(d),onIsPlayingChanged:d=>{this.syncButtons(),this.armAutoHide(),d&&this.maybeShowOnceOverlays()},onError:d=>{let c=this.q(".errorovl");c.hidden=!1,c.dataset.gen=String(e.currentLoadGeneration),this.lastSeenGeneration=e.currentLoadGeneration,c.textContent="";let h=document.createElement("span");if(h.textContent=this.cfg.errorMessageProvider?.(d)??`Playback error ${d.code}`,c.appendChild(h),this.cfg.showRetryButton){let u=document.createElement("button");u.className="retry",u.textContent=this.cfg.retryButtonLabel,u.addEventListener("click",f=>{f.stopPropagation(),e.retry()}),c.appendChild(u)}this.q(".buffering").hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null),this.errored=!0,this.hideControls()},onProgress:()=>this.syncProgress()};e.addListener(i),this.detachFns.push(()=>e.removeListener(i));let r=()=>{let d=document.fullscreenElement===this,c=d?this.dimF:this.dimE;this.q(".stage").classList.toggle("fs",d),this.style.setProperty("--edge",`${c.edgeInset}px`),this.style.setProperty("--rowh",`${c.bottomBarHeight}px`),this.style.setProperty("--rowpad",d?"8px":"4px");let h=this.q(".b-fs");h&&(h.innerHTML=this.glyph(d?"fullscreenExit":"fullscreenEnter",this.dimE.iconSize))};document.addEventListener("fullscreenchange",r),this.detachFns.push(()=>document.removeEventListener("fullscreenchange",r));let a=new ResizeObserver(()=>{this.applyCueSize(),this.playerRef?.notifyAdViewResize(this.clientWidth,this.clientHeight,document.fullscreenElement===this)});a.observe(this),this.detachFns.push(()=>a.disconnect()),e.onLicenseChanged(()=>this.syncWatermark());let o={onAdError:d=>{if(d.code!==902||this.cfg.adBlockerPolicy==="none")return;let c=this.q(".adblocknotice");c.dataset.gen=String(e.currentLoadGeneration),c.hidden=!1;let h=this.cfg.adBlockerPolicy==="block";c.classList.toggle("hard",h),this.q(".abclose").textContent=h?"I disabled it \u2014 reload":"Continue anyway",this.q(".abtext").textContent=h?"This video is only available with ads. Please disable your ad blocker for this site, then reload.":"This video is made available with ads, but your ad blocker prevented them from loading. Please allow ads for this site and reload the page.",h&&(this.q(".stage").classList.add("adblocked"),e.holdPlayback=!0,e.pause())}};e.addAdListener(o),this.detachFns.push(()=>e.removeAdListener(o)),this.q(".abclose").addEventListener("click",d=>{if(d.stopPropagation(),this.q(".adblocknotice").classList.contains("hard")){location.reload();return}this.q(".adblocknotice").hidden=!0});let l=window.setInterval(()=>this.syncPeriodic(),500);this.detachFns.push(()=>clearInterval(l))}bindScrub(){let e=this.playerRef,t=this.q(".scrub"),s=r=>{let a=t.getBoundingClientRect();return Math.min(1,Math.max(0,(r.clientX-a.left)/a.width))},i=()=>{let r=e.videoElement.seekable;return e.liveInfo&&r.length>0?[r.start(0)*1e3,r.end(r.length-1)*1e3]:[0,e.durationMs]};t.addEventListener("pointerdown",r=>{this.scrubbing=!0,t.classList.add("active"),t.setPointerCapture(r.pointerId),this.paintScrub(s(r)),this.showThumbPreview(s(r),i()),this.cancelAutoHide()}),t.addEventListener("pointermove",r=>{let a=s(r);this.scrubbing&&this.paintScrub(a),(this.scrubbing||r.pointerType==="mouse")&&this.showThumbPreview(a,i())}),t.addEventListener("pointerleave",()=>{this.scrubbing||this.hideThumbPreview()}),t.addEventListener("pointerup",r=>{if(!this.scrubbing)return;this.scrubbing=!1,t.classList.remove("active"),this.hideThumbPreview();let[a,o]=i();e.seekTo(a+s(r)*(o-a)),this.armAutoHide()})}thumbPreviewSeq=0;showThumbPreview(e,[t,s]){let i=this.playerRef,r=this.q(".thumbpreview"),a=t+e*(s-t);if(!i.hasThumbnails){if(!this.scrubbing){r.hidden=!0;return}r.hidden=!1,this.q(".tpimg").style.cssText="display:none",this.q(".tptime").textContent=Ls(a),r.style.left=`${e*100}%`;return}r.hidden=!1,r.style.left=`${e*100}%`,this.q(".tptime").textContent=Ls(a);let o=++this.thumbPreviewSeq;i.getThumbnail(a).then(l=>{if(o!==this.thumbPreviewSeq||!l)return;let d=this.q(".tpimg"),c=l.width>0?Math.min(1,168/l.width):1;l.width>0?(d.style.cssText=`display:block;width:${l.width*c}px;height:${l.height*c}px;background-image:url("${l.url}");background-position:-${l.x*c}px -${l.y*c}px;background-size:auto;`,d.style.backgroundSize=`${c===1?"auto":`calc(${(c*100).toFixed(2)}%) auto`}`):d.style.cssText=`display:block;width:168px;height:94px;background-image:url("${l.url}");background-size:cover;background-position:center;`})}hideThumbPreview(){this.q(".thumbpreview").hidden=!0}paintScrub(e){this.q(".played").style.width=`${e*100}%`,this.q(".thumb").style.left=`${e*100}%`}onState(e){e==="BUFFERING"&&(this.q(".errorovl").hidden=!0,this.errored=!1);let t=this.q(".buffering"),s=this.q(".ring");e==="BUFFERING"?(t.hidden=!1,s.hidden=!0,this.bufferingTimer===null&&(this.bufferingTimer=window.setTimeout(()=>{s.hidden=!1},250))):(t.hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)),this.q(".endeddim").hidden=e!=="ENDED",this.syncButtons()}maybeShowOnceOverlays(){let e=this.playerRef,t=e.currentLoadGeneration,s=e.currentItem;if(!s)return;if(t!==this.lastOverlayGeneration){this.lastOverlayGeneration=t,this.overlayTimers.forEach(a=>clearTimeout(a)),this.overlayTimers=[],this.setRatingRow(!1);let r=this.q(".title");r.hidden=!0,r.style.top="12px",this.q(".ratings").hidden=!0}if(this.cfg.showTitle&&s.title&&this.titleShownGeneration!==t){this.titleShownGeneration=t;let r=this.q(".title");r.textContent=s.title,r.hidden=!1,r.style.opacity="1",this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0"},this.cfg.titleTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.titleTimeoutMs+700))}let i=s.contentRatings??[];if(this.cfg.showContentRatings&&i.length>0&&this.ratingsShownGeneration!==t){this.ratingsShownGeneration=t;let r=this.q(".ratings");r.innerHTML=i.map(o=>this.ratingHtml(o)).join(""),r.hidden=!1,r.style.opacity="1",this.setRatingRow(!0),this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0",this.setRatingRow(!1)},this.cfg.contentRatingsTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.contentRatingsTimeoutMs+700));let a=this.q(".title");a.style.top="53px",this.overlayTimers.push(window.setTimeout(()=>{a.style.top="12px"},this.cfg.contentRatingsTimeoutMs))}}ratingHtml(e){return"age"in e?`<span class="age" style="background:${im[e.age]}">${sm[e.age]}</span>`:"descriptor"in e?`<span class="desc"><svg viewBox="0 0 24 24" width="16" height="16">${rm[e.descriptor]??""}</svg></span>`:`<img src="${e.customIconUrl}" alt="">`}setRatingRow(e){this.ratingRowVisible=e,this.q(".topend").style.paddingTop=e?"48px":"8px",this.applyOverlayInsets()}applyOverlayInsets(){let e=this.controlsVisible&&this.ratingRowVisible,t=this.controlsVisible||this.ratingRowVisible,i=Math.min(e?104:t?64:0,this.clientHeight*.5),r=this.controlsVisible?Math.min(68,this.clientHeight*.3):0;for(let a of["top-start","top-center","top-end"]){let o=this.q(`.ovl-${a}`),l=a==="top-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${i}px)`.trim()}for(let a of["bottom-start","bottom-center","bottom-end"]){let o=this.q(`.ovl-${a}`),l=a==="bottom-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${-r}px)`.trim()}this.q(".watermark").style.transform=`translateX(-50%) translateY(${this.ratingRowVisible?43:0}px)`}showControls(){this.errored||(this.controlsVisible=!0,this.q(".chrome").hidden=!1,this.applyOverlayInsets(),this.armAutoHide())}hideControls(){this.controlsVisible=!1,this.q(".chrome").hidden=!0,this.closeMenu(),this.applyOverlayInsets()}armAutoHide(){this.cancelAutoHide(),this.playerRef?.isPlaying&&(this.hideTimer=window.setTimeout(()=>{this.openMenu===null&&!this.scrubbing?this.hideControls():this.armAutoHide()},this.cfg.controlsTimeoutMs))}cancelAutoHide(){this.hideTimer!==null&&(clearTimeout(this.hideTimer),this.hideTimer=null)}syncAll(){this.syncButtons(),this.syncProgress(),this.syncWatermark(),this.applyCueSize(),this.applyOverlayInsets()}syncButtons(){let e=this.playerRef,t=this.q(".playpause"),s=e.state==="ENDED"?"replay":e.isPlaying?"pause":"play";t.innerHTML=this.glyph(s,44),t.setAttribute("aria-label",s==="pause"?"Pause":"Play");let i=this.q(".b-volume");i&&(i.innerHTML=this.glyph(e.isMuted||e.volume===0?"volumeMute":"volumeOn",this.dimE.iconSize))}syncProgress(){if(this.scrubbing)return;let e=this.playerRef,t=e.liveInfo,s=this.q(".time");if(t){let i=e.videoElement.seekable;if(i.length>0){let a=i.start(0),o=i.end(i.length-1),l=o>a?(e.videoElement.currentTime-a)/(o-a):1;this.paintScrub(Math.min(1,Math.max(0,l))),this.q(".buffered").style.width="0"}let r=t.latencyMs>12e3?` \u2212${Ls(t.latencyMs)}`:"";s.innerHTML=t.atLiveEdge?"":`<b>${r}</b>`}else{let i=e.durationMs,r=i>0?e.currentPositionMs/i:0;this.paintScrub(Math.min(1,r)),this.q(".buffered").style.width=`${i>0?Math.min(100,e.bufferedPositionMs/i*100):0}%`,s.innerHTML=`<b>${Ls(e.currentPositionMs)}</b> / ${Ls(i)}`,this.paintAdCues(i)}}paintAdCues(e){let t=this.playerRef,s=e>0&&this.cfg.showAdCueMarkers?t.adCuePoints.map(a=>a<0?1:Math.min(1,a*1e3/e)):[],i=s.map(a=>a.toFixed(3)).join(",");if(i===this.lastAdCueKey)return;this.lastAdCueKey=i;let r=this.q(".track");r.querySelectorAll(".cue").forEach(a=>a.remove());for(let a of s){let o=document.createElement("div");o.className="cue",o.style.left=`${a*100}%`,r.appendChild(o)}}syncPeriodic(){let e=this.playerRef;if(e.currentLoadGeneration!==this.lastSeenGeneration){this.lastSeenGeneration=e.currentLoadGeneration,this.q(".errorovl").hidden=!0,this.errored=!1;let c=this.q(".adblocknotice");c.dataset.gen!==String(e.currentLoadGeneration)&&(c.hidden=!0,this.q(".stage").classList.contains("adblocked")&&(this.q(".stage").classList.remove("adblocked"),e.holdPlayback=!1))}this.q(".stage").classList.contains("adblocked")&&e.isPlaying&&e.pause(),this.syncAdUi();let t=`${e.subtitleTextScale}|${e.subtitleStyle.textSizeFraction}|${e.subtitleStyle.foregroundColor}|${e.subtitleStyle.backgroundColor}|${e.subtitleStyle.edgeType}|${e.subtitleStyle.edgeColor}`;t!==this.lastCueKey&&(this.lastCueKey=t,this.applyCueSize());let s=e.liveInfo,i=this.q(".livechip");i.hidden=!s,s&&i.classList.toggle("behind",!s.atLiveEdge);let r=e.currentItem?.streamType??"VOD",a=r!=="LIVE",o=r!=="VOD";this.q(".scrub").hidden=!this.cfg.showProgressBar||!a,this.q(".time").hidden=!this.cfg.showTimeLabels||!a;let l=!this.cfg.showSeekButtons||!a;this.q(".seekback").hidden=l,this.q(".seekfwd").hidden=l;let d=this.root.querySelector(".b-speed");d&&(d.hidden=o||!this.cfg.showSpeedButton)}syncAdUi(){let e=this.playerRef,t=this.q(".stage");t.classList.toggle("adplaying",e.isPlayingAd),t.classList.toggle("adspending",e.adsPending);let s=this.q(".adchrome"),i=this.q(".adtransport"),r=e.adProgress;if(e.isPlayingAd&&r){s.hidden=!1,i.hidden=!1;let a=r.durationMs>0?Math.min(1,r.positionMs/r.durationMs):0;this.q(".adfill").style.width=`${a*100}%`,this.q(".adpod").textContent=r.adCount>1?`${r.adIndex}/${r.adCount}`:"";let o=Math.max(0,Math.ceil((r.durationMs-r.positionMs)/1e3));this.q(".adtime").textContent=`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`,i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground),i.setAttribute("aria-label",e.adPaused?"Resume ad":"Pause ad")}else s.hidden=!0,i.hidden=!e.isPlayingAd,e.isPlayingAd&&(i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground))}syncWatermark(){this.q(".watermark").hidden=this.playerRef?.isLicensed??!1}applyCueSize(){let e=this.playerRef;if(!e)return;let t=this.clientHeight||0,s=Math.max(13,Math.min(t*e.subtitleStyle.textSizeFraction,44))*e.subtitleTextScale,i=e.subtitleStyle,r=i.edgeColor,a=i.edgeType==="OUTLINE"?`text-shadow:-1px -1px 0 ${r},1px -1px 0 ${r},-1px 1px 0 ${r},1px 1px 0 ${r};`:i.edgeType==="DROP_SHADOW"?`text-shadow:2px 2px 3px ${r};`:i.edgeType==="RAISED"?`text-shadow:0 -1px 0 ${r};`:i.edgeType==="DEPRESSED"?`text-shadow:0 1px 0 ${r};`:"";this.q(".cuestyle").textContent=`video::cue { background:${i.backgroundColor}; color:${i.foregroundColor}; font-size:${s.toFixed(1)}px; ${a} }`}enterFullscreen(){return this.requestFullscreen()}exitFullscreen(){document.fullscreenElement===this&&document.exitFullscreen()}toggleFullscreen(){document.fullscreenElement===this?this.cfg.onFullscreenExitRequest?this.cfg.onFullscreenExitRequest():document.exitFullscreen():this.requestFullscreen()}detach(){this.detachFns.forEach(e=>e()),this.detachFns=[],this.overlayTimers.forEach(e=>clearTimeout(e)),this.overlayTimers=[],this.cancelAutoHide(),this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)}};function Ui(){customElements.get("og-player")||customElements.define("og-player",Rs)}var am="2026-08-18T23:37:17";Ui();return Wd(om);})();
|
|
285
|
+
<input type="range" min="0" max="100" value="${s.isMuted?0:Math.round(s.volume*100)}">`;let l=a.querySelector("input"),d=a.querySelector(".mmute"),c=()=>{d.innerHTML=o(),this.syncButtons()};l.addEventListener("input",()=>{s.volume=Number(l.value)/100,s.isMuted&&Number(l.value)>0&&(s.isMuted=!1),c()}),l.addEventListener("click",h=>h.stopPropagation()),d.addEventListener("click",h=>{h.stopPropagation(),s.isMuted=!s.isMuted,l.value=String(s.isMuted?0:Math.round(s.volume*100)),c()}),t.appendChild(a)}else if(e==="speed")nm.forEach(a=>r(a===1?"Normal":`${a}\xD7`,s.playbackSpeed===a,null,()=>{s.playbackSpeed=a}));else if(e==="quality"){let a=s.videoQualities;a.length===0&&r("Auto",!0,"adaptive",()=>{}),a.forEach(o=>r(o.id==="auto"?"Auto":`${o.height}p`,o.isSelected,o.id==="auto"?"adaptive":`${Math.round(o.bitrate/1e3)} kbps`,()=>s.selectVideoQuality(o.id)))}else if(e==="audio")s.audioTracks.forEach(a=>r(a.label,a.isSelected,a.language||null,()=>s.selectAudioTrack(a.id))),s.audioTracks.length===0&&r("Default",!0,null,()=>{});else if(e==="subs"){let a=s.textTracks;r("Off",!a.some(o=>o.isSelected),null,()=>s.selectTextTrack(null)),a.forEach(o=>r(o.label,o.isSelected,o.language||null,()=>s.selectTextTrack(o.id)))}}closeMenu(){this.openMenu=null,this.q(".menu").hidden=!0}bind(){let e=this.playerRef,t=this.q(".stage"),s=d=>{if(!d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub,.livechip")){if(this.openMenu){this.closeMenu();return}this.controlsVisible?this.hideControls():this.showControls()}};t.addEventListener("click",s),this.cfg.doubleClickToSeek&&t.addEventListener("dblclick",d=>{if(d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub"))return;let c=t.getBoundingClientRect();d.clientX-c.left<c.width/2?e.seekBackward():e.seekForward()}),this.q(".playpause").addEventListener("click",d=>{d.stopPropagation(),e.isPlaying?e.pause():e.play(),this.armAutoHide()}),this.q(".seekback").addEventListener("click",d=>{d.stopPropagation(),e.seekBackward(),this.armAutoHide()}),this.q(".seekfwd").addEventListener("click",d=>{d.stopPropagation(),e.seekForward(),this.armAutoHide()}),this.q(".livechip").addEventListener("click",d=>{d.stopPropagation(),e.seekToLiveEdge(),this.armAutoHide()}),this.q(".adtransport").addEventListener("click",d=>{d.stopPropagation(),e.adPaused?e.play():e.pause()}),this.bindScrub();let i={onStateChanged:d=>this.onState(d),onIsPlayingChanged:d=>{this.syncButtons(),this.armAutoHide(),d&&this.maybeShowOnceOverlays()},onError:d=>{let c=this.q(".errorovl");c.hidden=!1,c.dataset.gen=String(e.currentLoadGeneration),this.lastSeenGeneration=e.currentLoadGeneration,c.textContent="";let h=document.createElement("span");if(h.textContent=this.cfg.errorMessageProvider?.(d)??`Playback error ${d.code}`,c.appendChild(h),this.cfg.showRetryButton){let u=document.createElement("button");u.className="retry",u.textContent=this.cfg.retryButtonLabel,u.addEventListener("click",f=>{f.stopPropagation(),e.retry()}),c.appendChild(u)}this.q(".buffering").hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null),this.errored=!0,this.hideControls()},onProgress:()=>this.syncProgress()};e.addListener(i),this.detachFns.push(()=>e.removeListener(i));let r=()=>{let d=document.fullscreenElement===this,c=d?this.dimF:this.dimE;this.q(".stage").classList.toggle("fs",d),this.style.setProperty("--edge",`${c.edgeInset}px`),this.style.setProperty("--rowh",`${c.bottomBarHeight}px`),this.style.setProperty("--rowpad",d?"8px":"4px");let h=this.q(".b-fs");h&&(h.innerHTML=this.glyph(d?"fullscreenExit":"fullscreenEnter",this.dimE.iconSize))};document.addEventListener("fullscreenchange",r),this.detachFns.push(()=>document.removeEventListener("fullscreenchange",r));let a=new ResizeObserver(()=>{this.applyCueSize(),this.playerRef?.notifyAdViewResize(this.clientWidth,this.clientHeight,document.fullscreenElement===this)});a.observe(this),this.detachFns.push(()=>a.disconnect()),e.onLicenseChanged(()=>this.syncWatermark());let o={onAdError:d=>{if(d.code!==902||this.cfg.adBlockerPolicy==="none")return;let c=this.q(".adblocknotice");c.dataset.gen=String(e.currentLoadGeneration),c.hidden=!1;let h=this.cfg.adBlockerPolicy==="block";c.classList.toggle("hard",h),this.q(".abclose").textContent=h?"I disabled it \u2014 reload":"Continue anyway",this.q(".abtext").textContent=h?"This video is only available with ads. Please disable your ad blocker for this site, then reload.":"This video is made available with ads, but your ad blocker prevented them from loading. Please allow ads for this site and reload the page.",h&&(this.q(".stage").classList.add("adblocked"),e.holdPlayback=!0,e.pause())}};e.addAdListener(o),this.detachFns.push(()=>e.removeAdListener(o)),this.q(".abclose").addEventListener("click",d=>{if(d.stopPropagation(),this.q(".adblocknotice").classList.contains("hard")){location.reload();return}this.q(".adblocknotice").hidden=!0});let l=window.setInterval(()=>this.syncPeriodic(),500);this.detachFns.push(()=>clearInterval(l))}bindScrub(){let e=this.playerRef,t=this.q(".scrub"),s=r=>{let a=t.getBoundingClientRect();return Math.min(1,Math.max(0,(r.clientX-a.left)/a.width))},i=()=>{let r=e.videoElement.seekable;return e.liveInfo&&r.length>0?[r.start(0)*1e3,r.end(r.length-1)*1e3]:[0,e.durationMs]};t.addEventListener("pointerdown",r=>{this.scrubbing=!0,t.classList.add("active"),t.setPointerCapture(r.pointerId),this.paintScrub(s(r)),this.showThumbPreview(s(r),i()),this.cancelAutoHide()}),t.addEventListener("pointermove",r=>{let a=s(r);this.scrubbing&&this.paintScrub(a),(this.scrubbing||r.pointerType==="mouse")&&this.showThumbPreview(a,i())}),t.addEventListener("pointerleave",()=>{this.scrubbing||this.hideThumbPreview()}),t.addEventListener("pointerup",r=>{if(!this.scrubbing)return;this.scrubbing=!1,t.classList.remove("active"),this.hideThumbPreview();let[a,o]=i();e.seekTo(a+s(r)*(o-a)),this.armAutoHide()})}thumbPreviewSeq=0;showThumbPreview(e,[t,s]){let i=this.playerRef,r=this.q(".thumbpreview"),a=t+e*(s-t);if(!i.hasThumbnails){if(!this.scrubbing){r.hidden=!0;return}r.hidden=!1,this.q(".tpimg").style.cssText="display:none",this.q(".tptime").textContent=Ls(a),r.style.left=`${e*100}%`;return}r.hidden=!1,r.style.left=`${e*100}%`,this.q(".tptime").textContent=Ls(a);let o=++this.thumbPreviewSeq;i.getThumbnail(a).then(l=>{if(o!==this.thumbPreviewSeq||!l)return;let d=this.q(".tpimg"),c=l.width>0?Math.min(1,168/l.width):1;l.width>0?(d.style.cssText=`display:block;width:${l.width*c}px;height:${l.height*c}px;background-image:url("${l.url}");background-position:-${l.x*c}px -${l.y*c}px;background-size:auto;`,d.style.backgroundSize=`${c===1?"auto":`calc(${(c*100).toFixed(2)}%) auto`}`):d.style.cssText=`display:block;width:168px;height:94px;background-image:url("${l.url}");background-size:cover;background-position:center;`})}hideThumbPreview(){this.q(".thumbpreview").hidden=!0}paintScrub(e){this.q(".played").style.width=`${e*100}%`,this.q(".thumb").style.left=`${e*100}%`}onState(e){e==="BUFFERING"&&(this.q(".errorovl").hidden=!0,this.errored=!1);let t=this.q(".buffering"),s=this.q(".ring");e==="BUFFERING"?(t.hidden=!1,s.hidden=!0,this.bufferingTimer===null&&(this.bufferingTimer=window.setTimeout(()=>{s.hidden=!1},250))):(t.hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)),this.q(".endeddim").hidden=e!=="ENDED",this.syncButtons()}maybeShowOnceOverlays(){let e=this.playerRef,t=e.currentLoadGeneration,s=e.currentItem;if(!s)return;if(t!==this.lastOverlayGeneration){this.lastOverlayGeneration=t,this.overlayTimers.forEach(a=>clearTimeout(a)),this.overlayTimers=[],this.setRatingRow(!1);let r=this.q(".title");r.hidden=!0,r.style.top="12px",this.q(".ratings").hidden=!0}if(this.cfg.showTitle&&s.title&&this.titleShownGeneration!==t){this.titleShownGeneration=t;let r=this.q(".title");r.textContent=s.title,r.hidden=!1,r.style.opacity="1",this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0"},this.cfg.titleTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.titleTimeoutMs+700))}let i=s.contentRatings??[];if(this.cfg.showContentRatings&&i.length>0&&this.ratingsShownGeneration!==t){this.ratingsShownGeneration=t;let r=this.q(".ratings");r.innerHTML=i.map(o=>this.ratingHtml(o)).join(""),r.hidden=!1,r.style.opacity="1",this.setRatingRow(!0),this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0",this.setRatingRow(!1)},this.cfg.contentRatingsTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.contentRatingsTimeoutMs+700));let a=this.q(".title");a.style.top="53px",this.overlayTimers.push(window.setTimeout(()=>{a.style.top="12px"},this.cfg.contentRatingsTimeoutMs))}}ratingHtml(e){return"age"in e?`<span class="age" style="background:${im[e.age]}">${sm[e.age]}</span>`:"descriptor"in e?`<span class="desc"><svg viewBox="0 0 24 24" width="16" height="16">${rm[e.descriptor]??""}</svg></span>`:`<img src="${e.customIconUrl}" alt="">`}setRatingRow(e){this.ratingRowVisible=e,this.q(".topend").style.paddingTop=e?"48px":"8px",this.applyOverlayInsets()}applyOverlayInsets(){let e=this.controlsVisible&&this.ratingRowVisible,t=this.controlsVisible||this.ratingRowVisible,i=Math.min(e?104:t?64:0,this.clientHeight*.5),r=this.controlsVisible?Math.min(68,this.clientHeight*.3):0;for(let a of["top-start","top-center","top-end"]){let o=this.q(`.ovl-${a}`),l=a==="top-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${i}px)`.trim()}for(let a of["bottom-start","bottom-center","bottom-end"]){let o=this.q(`.ovl-${a}`),l=a==="bottom-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${-r}px)`.trim()}this.q(".watermark").style.transform=`translateX(-50%) translateY(${this.ratingRowVisible?43:0}px)`}showControls(){this.errored||(this.controlsVisible=!0,this.q(".chrome").hidden=!1,this.applyOverlayInsets(),this.armAutoHide())}hideControls(){this.controlsVisible=!1,this.q(".chrome").hidden=!0,this.closeMenu(),this.applyOverlayInsets()}armAutoHide(){this.cancelAutoHide(),this.playerRef?.isPlaying&&(this.hideTimer=window.setTimeout(()=>{this.openMenu===null&&!this.scrubbing?this.hideControls():this.armAutoHide()},this.cfg.controlsTimeoutMs))}cancelAutoHide(){this.hideTimer!==null&&(clearTimeout(this.hideTimer),this.hideTimer=null)}syncAll(){this.syncButtons(),this.syncProgress(),this.syncWatermark(),this.applyCueSize(),this.applyOverlayInsets()}syncButtons(){let e=this.playerRef,t=this.q(".playpause"),s=e.state==="ENDED"?"replay":e.isPlaying?"pause":"play";t.innerHTML=this.glyph(s,44),t.setAttribute("aria-label",s==="pause"?"Pause":"Play");let i=this.q(".b-volume");i&&(i.innerHTML=this.glyph(e.isMuted||e.volume===0?"volumeMute":"volumeOn",this.dimE.iconSize))}syncProgress(){if(this.scrubbing)return;let e=this.playerRef,t=e.liveInfo,s=this.q(".time");if(t){let i=e.videoElement.seekable;if(i.length>0){let a=i.start(0),o=i.end(i.length-1),l=o>a?(e.videoElement.currentTime-a)/(o-a):1;this.paintScrub(Math.min(1,Math.max(0,l))),this.q(".buffered").style.width="0"}let r=t.latencyMs>12e3?` \u2212${Ls(t.latencyMs)}`:"";s.innerHTML=t.atLiveEdge?"":`<b>${r}</b>`}else{let i=e.durationMs,r=i>0?e.currentPositionMs/i:0;this.paintScrub(Math.min(1,r)),this.q(".buffered").style.width=`${i>0?Math.min(100,e.bufferedPositionMs/i*100):0}%`,s.innerHTML=`<b>${Ls(e.currentPositionMs)}</b> / ${Ls(i)}`,this.paintAdCues(i)}}paintAdCues(e){let t=this.playerRef,s=e>0&&this.cfg.showAdCueMarkers?t.adCuePoints.map(a=>a<0?1:Math.min(1,a*1e3/e)):[],i=s.map(a=>a.toFixed(3)).join(",");if(i===this.lastAdCueKey)return;this.lastAdCueKey=i;let r=this.q(".track");r.querySelectorAll(".cue").forEach(a=>a.remove());for(let a of s){let o=document.createElement("div");o.className="cue",o.style.left=`${a*100}%`,r.appendChild(o)}}syncPeriodic(){let e=this.playerRef;if(e.currentLoadGeneration!==this.lastSeenGeneration){this.lastSeenGeneration=e.currentLoadGeneration,this.q(".errorovl").hidden=!0,this.errored=!1;let c=this.q(".adblocknotice");c.dataset.gen!==String(e.currentLoadGeneration)&&(c.hidden=!0,this.q(".stage").classList.contains("adblocked")&&(this.q(".stage").classList.remove("adblocked"),e.holdPlayback=!1))}this.q(".stage").classList.contains("adblocked")&&e.isPlaying&&e.pause(),this.syncAdUi();let t=`${e.subtitleTextScale}|${e.subtitleStyle.textSizeFraction}|${e.subtitleStyle.foregroundColor}|${e.subtitleStyle.backgroundColor}|${e.subtitleStyle.edgeType}|${e.subtitleStyle.edgeColor}`;t!==this.lastCueKey&&(this.lastCueKey=t,this.applyCueSize());let s=e.liveInfo,i=this.q(".livechip");i.hidden=!s,s&&i.classList.toggle("behind",!s.atLiveEdge);let r=e.currentItem?.streamType??"VOD",a=r!=="LIVE",o=r!=="VOD";this.q(".scrub").hidden=!this.cfg.showProgressBar||!a,this.q(".time").hidden=!this.cfg.showTimeLabels||!a;let l=!this.cfg.showSeekButtons||!a;this.q(".seekback").hidden=l,this.q(".seekfwd").hidden=l;let d=this.root.querySelector(".b-speed");d&&(d.hidden=o||!this.cfg.showSpeedButton)}syncAdUi(){let e=this.playerRef,t=this.q(".stage");t.classList.toggle("adplaying",e.isPlayingAd),t.classList.toggle("adspending",e.adsPending);let s=this.q(".adchrome"),i=this.q(".adtransport"),r=e.adProgress;if(e.isPlayingAd&&r){s.hidden=!1,i.hidden=!1;let a=r.durationMs>0?Math.min(1,r.positionMs/r.durationMs):0;this.q(".adfill").style.width=`${a*100}%`,this.q(".adpod").textContent=r.adCount>1?`${r.adIndex}/${r.adCount}`:"";let o=Math.max(0,Math.ceil((r.durationMs-r.positionMs)/1e3));this.q(".adtime").textContent=`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`,i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground),i.setAttribute("aria-label",e.adPaused?"Resume ad":"Pause ad")}else s.hidden=!0,i.hidden=!e.isPlayingAd,e.isPlayingAd&&(i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground))}syncWatermark(){this.q(".watermark").hidden=this.playerRef?.isLicensed??!1}applyCueSize(){let e=this.playerRef;if(!e)return;let t=this.clientHeight||0,s=Math.max(13,Math.min(t*e.subtitleStyle.textSizeFraction,44))*e.subtitleTextScale,i=e.subtitleStyle,r=i.edgeColor,a=i.edgeType==="OUTLINE"?`text-shadow:-1px -1px 0 ${r},1px -1px 0 ${r},-1px 1px 0 ${r},1px 1px 0 ${r};`:i.edgeType==="DROP_SHADOW"?`text-shadow:2px 2px 3px ${r};`:i.edgeType==="RAISED"?`text-shadow:0 -1px 0 ${r};`:i.edgeType==="DEPRESSED"?`text-shadow:0 1px 0 ${r};`:"";this.q(".cuestyle").textContent=`video::cue { background:${i.backgroundColor}; color:${i.foregroundColor}; font-size:${s.toFixed(1)}px; ${a} }`}enterFullscreen(){return this.requestFullscreen()}exitFullscreen(){document.fullscreenElement===this&&document.exitFullscreen()}toggleFullscreen(){document.fullscreenElement===this?this.cfg.onFullscreenExitRequest?this.cfg.onFullscreenExitRequest():document.exitFullscreen():this.requestFullscreen()}detach(){this.detachFns.forEach(e=>e()),this.detachFns=[],this.overlayTimers.forEach(e=>clearTimeout(e)),this.overlayTimers=[],this.cancelAutoHide(),this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)}};function Ui(){customElements.get("og-player")||customElements.define("og-player",Rs)}var am="2026-08-19T00:25:00";Ui();return Wd(om);})();
|
package/dist/ogplayer.js
CHANGED
|
@@ -282,4 +282,4 @@ Schedule: ${l.map(m=>Ue(m))} pos: ${this.timelinePos}`),c.length&&this.log(`Remo
|
|
|
282
282
|
.fs .ratings .age, .fs .ratings .desc { width:36px; height:36px; font-size:16px; }
|
|
283
283
|
`}buildButtons(){let e=this.q(".buttons");e.innerHTML="";let t=(r,a,o)=>{let l=document.createElement("button");return l.className=`bbtn b-${r}`,l.innerHTML=this.glyph(a,this.dimE.iconSize),l.addEventListener("click",d=>{d.stopPropagation(),o(),this.armAutoHide()}),e.appendChild(l),l};this.cfg.showVolumeButton&&t("volume","volumeOn",()=>this.toggleMenu("volume")),this.cfg.showSpeedButton&&t("speed","speed",()=>this.toggleMenu("speed")),this.cfg.showQualityButton&&t("quality","quality",()=>this.toggleMenu("quality")),this.cfg.showAudioTrackButton&&t("audio","audioTrack",()=>this.toggleMenu("audio")),this.cfg.showSubtitleButton&&t("subs","subtitles",()=>this.toggleMenu("subs")),this.cfg.showFullscreenButton&&t("fs","fullscreenEnter",()=>this.toggleFullscreen());let s=this.q(".seekback"),i=this.q(".seekfwd");s.hidden=i.hidden=!this.cfg.showSeekButtons,this.q(".seekback .seeknum").textContent=String(Math.round((this.playerRef?.seekBackwardIncrementMs??1e4)/1e3)),this.q(".seekfwd .seeknum").textContent=String(Math.round((this.playerRef?.seekForwardIncrementMs??1e4)/1e3)),this.q(".scrub").hidden=!this.cfg.showProgressBar,this.q(".time").hidden=!this.cfg.showTimeLabels}buildTopEnd(){let e=this.q(".topend");e.innerHTML="",this.cfg.customActions.slice(0,8).forEach((t,s)=>{let i=document.createElement("button");i.className="abtn",i.setAttribute("aria-label",t.accessibilityLabel??`Custom action ${s+1}`),i.innerHTML=t.svg;let r=i.querySelector("svg");r&&(r.style.color=this.col.foreground,r.setAttribute("fill","currentColor")),i.addEventListener("click",a=>{a.stopPropagation(),t.onClick(),this.armAutoHide()}),e.appendChild(i)})}toggleMenu(e){if(this.openMenu===e){this.closeMenu();return}this.openMenu=e;let t=this.q(".menu");t.hidden=!1,t.classList.toggle("narrow",e==="volume"),t.innerHTML="";let s=this.playerRef,i=this.col,r=(a,o,l,d)=>{let c=document.createElement("div");c.className="mitem",c.innerHTML=`<span class="mcheck">${o?wt("check",18,i.adAccent):""}</span>
|
|
284
284
|
<span>${a}</span>${l?`<span class="msub">${l}</span>`:""}`,c.addEventListener("click",h=>{h.stopPropagation(),d(),this.closeMenu(),this.armAutoHide()}),t.appendChild(c)};if(e==="volume"){let a=document.createElement("div");a.className="mitem vol";let o=()=>this.glyph(s.isMuted||s.volume===0?"volumeMute":"volumeOn",22);a.innerHTML=`<button class="mmute" aria-label="Mute">${o()}</button>
|
|
285
|
-
<input type="range" min="0" max="100" value="${s.isMuted?0:Math.round(s.volume*100)}">`;let l=a.querySelector("input"),d=a.querySelector(".mmute"),c=()=>{d.innerHTML=o(),this.syncButtons()};l.addEventListener("input",()=>{s.volume=Number(l.value)/100,s.isMuted&&Number(l.value)>0&&(s.isMuted=!1),c()}),l.addEventListener("click",h=>h.stopPropagation()),d.addEventListener("click",h=>{h.stopPropagation(),s.isMuted=!s.isMuted,l.value=String(s.isMuted?0:Math.round(s.volume*100)),c()}),t.appendChild(a)}else if(e==="speed")Qg.forEach(a=>r(a===1?"Normal":`${a}\xD7`,s.playbackSpeed===a,null,()=>{s.playbackSpeed=a}));else if(e==="quality"){let a=s.videoQualities;a.length===0&&r("Auto",!0,"adaptive",()=>{}),a.forEach(o=>r(o.id==="auto"?"Auto":`${o.height}p`,o.isSelected,o.id==="auto"?"adaptive":`${Math.round(o.bitrate/1e3)} kbps`,()=>s.selectVideoQuality(o.id)))}else if(e==="audio")s.audioTracks.forEach(a=>r(a.label,a.isSelected,a.language||null,()=>s.selectAudioTrack(a.id))),s.audioTracks.length===0&&r("Default",!0,null,()=>{});else if(e==="subs"){let a=s.textTracks;r("Off",!a.some(o=>o.isSelected),null,()=>s.selectTextTrack(null)),a.forEach(o=>r(o.label,o.isSelected,o.language||null,()=>s.selectTextTrack(o.id)))}}closeMenu(){this.openMenu=null,this.q(".menu").hidden=!0}bind(){let e=this.playerRef,t=this.q(".stage"),s=d=>{if(!d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub,.livechip")){if(this.openMenu){this.closeMenu();return}this.controlsVisible?this.hideControls():this.showControls()}};t.addEventListener("click",s),this.cfg.doubleClickToSeek&&t.addEventListener("dblclick",d=>{if(d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub"))return;let c=t.getBoundingClientRect();d.clientX-c.left<c.width/2?e.seekBackward():e.seekForward()}),this.q(".playpause").addEventListener("click",d=>{d.stopPropagation(),e.isPlaying?e.pause():e.play(),this.armAutoHide()}),this.q(".seekback").addEventListener("click",d=>{d.stopPropagation(),e.seekBackward(),this.armAutoHide()}),this.q(".seekfwd").addEventListener("click",d=>{d.stopPropagation(),e.seekForward(),this.armAutoHide()}),this.q(".livechip").addEventListener("click",d=>{d.stopPropagation(),e.seekToLiveEdge(),this.armAutoHide()}),this.q(".adtransport").addEventListener("click",d=>{d.stopPropagation(),e.adPaused?e.play():e.pause()}),this.bindScrub();let i={onStateChanged:d=>this.onState(d),onIsPlayingChanged:d=>{this.syncButtons(),this.armAutoHide(),d&&this.maybeShowOnceOverlays()},onError:d=>{let c=this.q(".errorovl");c.hidden=!1,c.dataset.gen=String(e.currentLoadGeneration),this.lastSeenGeneration=e.currentLoadGeneration,c.textContent="";let h=document.createElement("span");if(h.textContent=this.cfg.errorMessageProvider?.(d)??`Playback error ${d.code}`,c.appendChild(h),this.cfg.showRetryButton){let u=document.createElement("button");u.className="retry",u.textContent=this.cfg.retryButtonLabel,u.addEventListener("click",f=>{f.stopPropagation(),e.retry()}),c.appendChild(u)}this.q(".buffering").hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null),this.errored=!0,this.hideControls()},onProgress:()=>this.syncProgress()};e.addListener(i),this.detachFns.push(()=>e.removeListener(i));let r=()=>{let d=document.fullscreenElement===this,c=d?this.dimF:this.dimE;this.q(".stage").classList.toggle("fs",d),this.style.setProperty("--edge",`${c.edgeInset}px`),this.style.setProperty("--rowh",`${c.bottomBarHeight}px`),this.style.setProperty("--rowpad",d?"8px":"4px");let h=this.q(".b-fs");h&&(h.innerHTML=this.glyph(d?"fullscreenExit":"fullscreenEnter",this.dimE.iconSize))};document.addEventListener("fullscreenchange",r),this.detachFns.push(()=>document.removeEventListener("fullscreenchange",r));let a=new ResizeObserver(()=>{this.applyCueSize(),this.playerRef?.notifyAdViewResize(this.clientWidth,this.clientHeight,document.fullscreenElement===this)});a.observe(this),this.detachFns.push(()=>a.disconnect()),e.onLicenseChanged(()=>this.syncWatermark());let o={onAdError:d=>{if(d.code!==902||this.cfg.adBlockerPolicy==="none")return;let c=this.q(".adblocknotice");c.dataset.gen=String(e.currentLoadGeneration),c.hidden=!1;let h=this.cfg.adBlockerPolicy==="block";c.classList.toggle("hard",h),this.q(".abclose").textContent=h?"I disabled it \u2014 reload":"Continue anyway",this.q(".abtext").textContent=h?"This video is only available with ads. Please disable your ad blocker for this site, then reload.":"This video is made available with ads, but your ad blocker prevented them from loading. Please allow ads for this site and reload the page.",h&&(this.q(".stage").classList.add("adblocked"),e.holdPlayback=!0,e.pause())}};e.addAdListener(o),this.detachFns.push(()=>e.removeAdListener(o)),this.q(".abclose").addEventListener("click",d=>{if(d.stopPropagation(),this.q(".adblocknotice").classList.contains("hard")){location.reload();return}this.q(".adblocknotice").hidden=!0});let l=window.setInterval(()=>this.syncPeriodic(),500);this.detachFns.push(()=>clearInterval(l))}bindScrub(){let e=this.playerRef,t=this.q(".scrub"),s=r=>{let a=t.getBoundingClientRect();return Math.min(1,Math.max(0,(r.clientX-a.left)/a.width))},i=()=>{let r=e.videoElement.seekable;return e.liveInfo&&r.length>0?[r.start(0)*1e3,r.end(r.length-1)*1e3]:[0,e.durationMs]};t.addEventListener("pointerdown",r=>{this.scrubbing=!0,t.classList.add("active"),t.setPointerCapture(r.pointerId),this.paintScrub(s(r)),this.showThumbPreview(s(r),i()),this.cancelAutoHide()}),t.addEventListener("pointermove",r=>{let a=s(r);this.scrubbing&&this.paintScrub(a),(this.scrubbing||r.pointerType==="mouse")&&this.showThumbPreview(a,i())}),t.addEventListener("pointerleave",()=>{this.scrubbing||this.hideThumbPreview()}),t.addEventListener("pointerup",r=>{if(!this.scrubbing)return;this.scrubbing=!1,t.classList.remove("active"),this.hideThumbPreview();let[a,o]=i();e.seekTo(a+s(r)*(o-a)),this.armAutoHide()})}thumbPreviewSeq=0;showThumbPreview(e,[t,s]){let i=this.playerRef,r=this.q(".thumbpreview"),a=t+e*(s-t);if(!i.hasThumbnails){if(!this.scrubbing){r.hidden=!0;return}r.hidden=!1,this.q(".tpimg").style.cssText="display:none",this.q(".tptime").textContent=xs(a),r.style.left=`${e*100}%`;return}r.hidden=!1,r.style.left=`${e*100}%`,this.q(".tptime").textContent=xs(a);let o=++this.thumbPreviewSeq;i.getThumbnail(a).then(l=>{if(o!==this.thumbPreviewSeq||!l)return;let d=this.q(".tpimg"),c=l.width>0?Math.min(1,168/l.width):1;l.width>0?(d.style.cssText=`display:block;width:${l.width*c}px;height:${l.height*c}px;background-image:url("${l.url}");background-position:-${l.x*c}px -${l.y*c}px;background-size:auto;`,d.style.backgroundSize=`${c===1?"auto":`calc(${(c*100).toFixed(2)}%) auto`}`):d.style.cssText=`display:block;width:168px;height:94px;background-image:url("${l.url}");background-size:cover;background-position:center;`})}hideThumbPreview(){this.q(".thumbpreview").hidden=!0}paintScrub(e){this.q(".played").style.width=`${e*100}%`,this.q(".thumb").style.left=`${e*100}%`}onState(e){e==="BUFFERING"&&(this.q(".errorovl").hidden=!0,this.errored=!1);let t=this.q(".buffering"),s=this.q(".ring");e==="BUFFERING"?(t.hidden=!1,s.hidden=!0,this.bufferingTimer===null&&(this.bufferingTimer=window.setTimeout(()=>{s.hidden=!1},250))):(t.hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)),this.q(".endeddim").hidden=e!=="ENDED",this.syncButtons()}maybeShowOnceOverlays(){let e=this.playerRef,t=e.currentLoadGeneration,s=e.currentItem;if(!s)return;if(t!==this.lastOverlayGeneration){this.lastOverlayGeneration=t,this.overlayTimers.forEach(a=>clearTimeout(a)),this.overlayTimers=[],this.setRatingRow(!1);let r=this.q(".title");r.hidden=!0,r.style.top="12px",this.q(".ratings").hidden=!0}if(this.cfg.showTitle&&s.title&&this.titleShownGeneration!==t){this.titleShownGeneration=t;let r=this.q(".title");r.textContent=s.title,r.hidden=!1,r.style.opacity="1",this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0"},this.cfg.titleTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.titleTimeoutMs+700))}let i=s.contentRatings??[];if(this.cfg.showContentRatings&&i.length>0&&this.ratingsShownGeneration!==t){this.ratingsShownGeneration=t;let r=this.q(".ratings");r.innerHTML=i.map(o=>this.ratingHtml(o)).join(""),r.hidden=!1,r.style.opacity="1",this.setRatingRow(!0),this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0",this.setRatingRow(!1)},this.cfg.contentRatingsTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.contentRatingsTimeoutMs+700));let a=this.q(".title");a.style.top="53px",this.overlayTimers.push(window.setTimeout(()=>{a.style.top="12px"},this.cfg.contentRatingsTimeoutMs))}}ratingHtml(e){return"age"in e?`<span class="age" style="background:${zg[e.age]}">${jg[e.age]}</span>`:"descriptor"in e?`<span class="desc"><svg viewBox="0 0 24 24" width="16" height="16">${Xg[e.descriptor]??""}</svg></span>`:`<img src="${e.customIconUrl}" alt="">`}setRatingRow(e){this.ratingRowVisible=e,this.q(".topend").style.paddingTop=e?"48px":"8px",this.applyOverlayInsets()}applyOverlayInsets(){let e=this.controlsVisible&&this.ratingRowVisible,t=this.controlsVisible||this.ratingRowVisible,i=Math.min(e?104:t?64:0,this.clientHeight*.5),r=this.controlsVisible?Math.min(68,this.clientHeight*.3):0;for(let a of["top-start","top-center","top-end"]){let o=this.q(`.ovl-${a}`),l=a==="top-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${i}px)`.trim()}for(let a of["bottom-start","bottom-center","bottom-end"]){let o=this.q(`.ovl-${a}`),l=a==="bottom-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${-r}px)`.trim()}this.q(".watermark").style.transform=`translateX(-50%) translateY(${this.ratingRowVisible?43:0}px)`}showControls(){this.errored||(this.controlsVisible=!0,this.q(".chrome").hidden=!1,this.applyOverlayInsets(),this.armAutoHide())}hideControls(){this.controlsVisible=!1,this.q(".chrome").hidden=!0,this.closeMenu(),this.applyOverlayInsets()}armAutoHide(){this.cancelAutoHide(),this.playerRef?.isPlaying&&(this.hideTimer=window.setTimeout(()=>{this.openMenu===null&&!this.scrubbing?this.hideControls():this.armAutoHide()},this.cfg.controlsTimeoutMs))}cancelAutoHide(){this.hideTimer!==null&&(clearTimeout(this.hideTimer),this.hideTimer=null)}syncAll(){this.syncButtons(),this.syncProgress(),this.syncWatermark(),this.applyCueSize(),this.applyOverlayInsets()}syncButtons(){let e=this.playerRef,t=this.q(".playpause"),s=e.state==="ENDED"?"replay":e.isPlaying?"pause":"play";t.innerHTML=this.glyph(s,44),t.setAttribute("aria-label",s==="pause"?"Pause":"Play");let i=this.q(".b-volume");i&&(i.innerHTML=this.glyph(e.isMuted||e.volume===0?"volumeMute":"volumeOn",this.dimE.iconSize))}syncProgress(){if(this.scrubbing)return;let e=this.playerRef,t=e.liveInfo,s=this.q(".time");if(t){let i=e.videoElement.seekable;if(i.length>0){let a=i.start(0),o=i.end(i.length-1),l=o>a?(e.videoElement.currentTime-a)/(o-a):1;this.paintScrub(Math.min(1,Math.max(0,l))),this.q(".buffered").style.width="0"}let r=t.latencyMs>12e3?` \u2212${xs(t.latencyMs)}`:"";s.innerHTML=t.atLiveEdge?"":`<b>${r}</b>`}else{let i=e.durationMs,r=i>0?e.currentPositionMs/i:0;this.paintScrub(Math.min(1,r)),this.q(".buffered").style.width=`${i>0?Math.min(100,e.bufferedPositionMs/i*100):0}%`,s.innerHTML=`<b>${xs(e.currentPositionMs)}</b> / ${xs(i)}`,this.paintAdCues(i)}}paintAdCues(e){let t=this.playerRef,s=e>0&&this.cfg.showAdCueMarkers?t.adCuePoints.map(a=>a<0?1:Math.min(1,a*1e3/e)):[],i=s.map(a=>a.toFixed(3)).join(",");if(i===this.lastAdCueKey)return;this.lastAdCueKey=i;let r=this.q(".track");r.querySelectorAll(".cue").forEach(a=>a.remove());for(let a of s){let o=document.createElement("div");o.className="cue",o.style.left=`${a*100}%`,r.appendChild(o)}}syncPeriodic(){let e=this.playerRef;if(e.currentLoadGeneration!==this.lastSeenGeneration){this.lastSeenGeneration=e.currentLoadGeneration,this.q(".errorovl").hidden=!0,this.errored=!1;let c=this.q(".adblocknotice");c.dataset.gen!==String(e.currentLoadGeneration)&&(c.hidden=!0,this.q(".stage").classList.contains("adblocked")&&(this.q(".stage").classList.remove("adblocked"),e.holdPlayback=!1))}this.q(".stage").classList.contains("adblocked")&&e.isPlaying&&e.pause(),this.syncAdUi();let t=`${e.subtitleTextScale}|${e.subtitleStyle.textSizeFraction}|${e.subtitleStyle.foregroundColor}|${e.subtitleStyle.backgroundColor}|${e.subtitleStyle.edgeType}|${e.subtitleStyle.edgeColor}`;t!==this.lastCueKey&&(this.lastCueKey=t,this.applyCueSize());let s=e.liveInfo,i=this.q(".livechip");i.hidden=!s,s&&i.classList.toggle("behind",!s.atLiveEdge);let r=e.currentItem?.streamType??"VOD",a=r!=="LIVE",o=r!=="VOD";this.q(".scrub").hidden=!this.cfg.showProgressBar||!a,this.q(".time").hidden=!this.cfg.showTimeLabels||!a;let l=!this.cfg.showSeekButtons||!a;this.q(".seekback").hidden=l,this.q(".seekfwd").hidden=l;let d=this.root.querySelector(".b-speed");d&&(d.hidden=o||!this.cfg.showSpeedButton)}syncAdUi(){let e=this.playerRef,t=this.q(".stage");t.classList.toggle("adplaying",e.isPlayingAd),t.classList.toggle("adspending",e.adsPending);let s=this.q(".adchrome"),i=this.q(".adtransport"),r=e.adProgress;if(e.isPlayingAd&&r){s.hidden=!1,i.hidden=!1;let a=r.durationMs>0?Math.min(1,r.positionMs/r.durationMs):0;this.q(".adfill").style.width=`${a*100}%`,this.q(".adpod").textContent=r.adCount>1?`${r.adIndex}/${r.adCount}`:"";let o=Math.max(0,Math.ceil((r.durationMs-r.positionMs)/1e3));this.q(".adtime").textContent=`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`,i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground),i.setAttribute("aria-label",e.adPaused?"Resume ad":"Pause ad")}else s.hidden=!0,i.hidden=!e.isPlayingAd,e.isPlayingAd&&(i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground))}syncWatermark(){this.q(".watermark").hidden=this.playerRef?.isLicensed??!1}applyCueSize(){let e=this.playerRef;if(!e)return;let t=this.clientHeight||0,s=Math.max(13,Math.min(t*e.subtitleStyle.textSizeFraction,44))*e.subtitleTextScale,i=e.subtitleStyle,r=i.edgeColor,a=i.edgeType==="OUTLINE"?`text-shadow:-1px -1px 0 ${r},1px -1px 0 ${r},-1px 1px 0 ${r},1px 1px 0 ${r};`:i.edgeType==="DROP_SHADOW"?`text-shadow:2px 2px 3px ${r};`:i.edgeType==="RAISED"?`text-shadow:0 -1px 0 ${r};`:i.edgeType==="DEPRESSED"?`text-shadow:0 1px 0 ${r};`:"";this.q(".cuestyle").textContent=`video::cue { background:${i.backgroundColor}; color:${i.foregroundColor}; font-size:${s.toFixed(1)}px; ${a} }`}enterFullscreen(){return this.requestFullscreen()}exitFullscreen(){document.fullscreenElement===this&&document.exitFullscreen()}toggleFullscreen(){document.fullscreenElement===this?this.cfg.onFullscreenExitRequest?this.cfg.onFullscreenExitRequest():document.exitFullscreen():this.requestFullscreen()}detach(){this.detachFns.forEach(e=>e()),this.detachFns=[],this.overlayTimers.forEach(e=>clearTimeout(e)),this.overlayTimers=[],this.cancelAutoHide(),this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)}};function da(){customElements.get("og-player")||customElements.define("og-player",wi)}var Cm="2026-08-18T23:37:17";da();export{nm as DEFAULT_TEXT_SIZE_FRACTION,ue as ErrorCodes,oa as FreewheelAdsProvider,na as ImaAdsProvider,Cm as OGPLAYER_BUILD,am as OGPLAYER_VERSION,ia as OGPlayer,wi as OGPlayerElement,Di as defaultColors,Pd as defaultSubtitleStyle,la as defaultUIConfig,da as defineOGPlayerElement,bs as embeddedDimens,ra as freewheelVmapTagUrl,ki as fullscreenDimens,Wg as hidingAllControls,As as isFreewheelConfig,sa as verifyLicense};
|
|
285
|
+
<input type="range" min="0" max="100" value="${s.isMuted?0:Math.round(s.volume*100)}">`;let l=a.querySelector("input"),d=a.querySelector(".mmute"),c=()=>{d.innerHTML=o(),this.syncButtons()};l.addEventListener("input",()=>{s.volume=Number(l.value)/100,s.isMuted&&Number(l.value)>0&&(s.isMuted=!1),c()}),l.addEventListener("click",h=>h.stopPropagation()),d.addEventListener("click",h=>{h.stopPropagation(),s.isMuted=!s.isMuted,l.value=String(s.isMuted?0:Math.round(s.volume*100)),c()}),t.appendChild(a)}else if(e==="speed")Qg.forEach(a=>r(a===1?"Normal":`${a}\xD7`,s.playbackSpeed===a,null,()=>{s.playbackSpeed=a}));else if(e==="quality"){let a=s.videoQualities;a.length===0&&r("Auto",!0,"adaptive",()=>{}),a.forEach(o=>r(o.id==="auto"?"Auto":`${o.height}p`,o.isSelected,o.id==="auto"?"adaptive":`${Math.round(o.bitrate/1e3)} kbps`,()=>s.selectVideoQuality(o.id)))}else if(e==="audio")s.audioTracks.forEach(a=>r(a.label,a.isSelected,a.language||null,()=>s.selectAudioTrack(a.id))),s.audioTracks.length===0&&r("Default",!0,null,()=>{});else if(e==="subs"){let a=s.textTracks;r("Off",!a.some(o=>o.isSelected),null,()=>s.selectTextTrack(null)),a.forEach(o=>r(o.label,o.isSelected,o.language||null,()=>s.selectTextTrack(o.id)))}}closeMenu(){this.openMenu=null,this.q(".menu").hidden=!0}bind(){let e=this.playerRef,t=this.q(".stage"),s=d=>{if(!d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub,.livechip")){if(this.openMenu){this.closeMenu();return}this.controlsVisible?this.hideControls():this.showControls()}};t.addEventListener("click",s),this.cfg.doubleClickToSeek&&t.addEventListener("dblclick",d=>{if(d.target.closest(".cbtn,.bbtn,.abtn,.menu,.scrub"))return;let c=t.getBoundingClientRect();d.clientX-c.left<c.width/2?e.seekBackward():e.seekForward()}),this.q(".playpause").addEventListener("click",d=>{d.stopPropagation(),e.isPlaying?e.pause():e.play(),this.armAutoHide()}),this.q(".seekback").addEventListener("click",d=>{d.stopPropagation(),e.seekBackward(),this.armAutoHide()}),this.q(".seekfwd").addEventListener("click",d=>{d.stopPropagation(),e.seekForward(),this.armAutoHide()}),this.q(".livechip").addEventListener("click",d=>{d.stopPropagation(),e.seekToLiveEdge(),this.armAutoHide()}),this.q(".adtransport").addEventListener("click",d=>{d.stopPropagation(),e.adPaused?e.play():e.pause()}),this.bindScrub();let i={onStateChanged:d=>this.onState(d),onIsPlayingChanged:d=>{this.syncButtons(),this.armAutoHide(),d&&this.maybeShowOnceOverlays()},onError:d=>{let c=this.q(".errorovl");c.hidden=!1,c.dataset.gen=String(e.currentLoadGeneration),this.lastSeenGeneration=e.currentLoadGeneration,c.textContent="";let h=document.createElement("span");if(h.textContent=this.cfg.errorMessageProvider?.(d)??`Playback error ${d.code}`,c.appendChild(h),this.cfg.showRetryButton){let u=document.createElement("button");u.className="retry",u.textContent=this.cfg.retryButtonLabel,u.addEventListener("click",f=>{f.stopPropagation(),e.retry()}),c.appendChild(u)}this.q(".buffering").hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null),this.errored=!0,this.hideControls()},onProgress:()=>this.syncProgress()};e.addListener(i),this.detachFns.push(()=>e.removeListener(i));let r=()=>{let d=document.fullscreenElement===this,c=d?this.dimF:this.dimE;this.q(".stage").classList.toggle("fs",d),this.style.setProperty("--edge",`${c.edgeInset}px`),this.style.setProperty("--rowh",`${c.bottomBarHeight}px`),this.style.setProperty("--rowpad",d?"8px":"4px");let h=this.q(".b-fs");h&&(h.innerHTML=this.glyph(d?"fullscreenExit":"fullscreenEnter",this.dimE.iconSize))};document.addEventListener("fullscreenchange",r),this.detachFns.push(()=>document.removeEventListener("fullscreenchange",r));let a=new ResizeObserver(()=>{this.applyCueSize(),this.playerRef?.notifyAdViewResize(this.clientWidth,this.clientHeight,document.fullscreenElement===this)});a.observe(this),this.detachFns.push(()=>a.disconnect()),e.onLicenseChanged(()=>this.syncWatermark());let o={onAdError:d=>{if(d.code!==902||this.cfg.adBlockerPolicy==="none")return;let c=this.q(".adblocknotice");c.dataset.gen=String(e.currentLoadGeneration),c.hidden=!1;let h=this.cfg.adBlockerPolicy==="block";c.classList.toggle("hard",h),this.q(".abclose").textContent=h?"I disabled it \u2014 reload":"Continue anyway",this.q(".abtext").textContent=h?"This video is only available with ads. Please disable your ad blocker for this site, then reload.":"This video is made available with ads, but your ad blocker prevented them from loading. Please allow ads for this site and reload the page.",h&&(this.q(".stage").classList.add("adblocked"),e.holdPlayback=!0,e.pause())}};e.addAdListener(o),this.detachFns.push(()=>e.removeAdListener(o)),this.q(".abclose").addEventListener("click",d=>{if(d.stopPropagation(),this.q(".adblocknotice").classList.contains("hard")){location.reload();return}this.q(".adblocknotice").hidden=!0});let l=window.setInterval(()=>this.syncPeriodic(),500);this.detachFns.push(()=>clearInterval(l))}bindScrub(){let e=this.playerRef,t=this.q(".scrub"),s=r=>{let a=t.getBoundingClientRect();return Math.min(1,Math.max(0,(r.clientX-a.left)/a.width))},i=()=>{let r=e.videoElement.seekable;return e.liveInfo&&r.length>0?[r.start(0)*1e3,r.end(r.length-1)*1e3]:[0,e.durationMs]};t.addEventListener("pointerdown",r=>{this.scrubbing=!0,t.classList.add("active"),t.setPointerCapture(r.pointerId),this.paintScrub(s(r)),this.showThumbPreview(s(r),i()),this.cancelAutoHide()}),t.addEventListener("pointermove",r=>{let a=s(r);this.scrubbing&&this.paintScrub(a),(this.scrubbing||r.pointerType==="mouse")&&this.showThumbPreview(a,i())}),t.addEventListener("pointerleave",()=>{this.scrubbing||this.hideThumbPreview()}),t.addEventListener("pointerup",r=>{if(!this.scrubbing)return;this.scrubbing=!1,t.classList.remove("active"),this.hideThumbPreview();let[a,o]=i();e.seekTo(a+s(r)*(o-a)),this.armAutoHide()})}thumbPreviewSeq=0;showThumbPreview(e,[t,s]){let i=this.playerRef,r=this.q(".thumbpreview"),a=t+e*(s-t);if(!i.hasThumbnails){if(!this.scrubbing){r.hidden=!0;return}r.hidden=!1,this.q(".tpimg").style.cssText="display:none",this.q(".tptime").textContent=xs(a),r.style.left=`${e*100}%`;return}r.hidden=!1,r.style.left=`${e*100}%`,this.q(".tptime").textContent=xs(a);let o=++this.thumbPreviewSeq;i.getThumbnail(a).then(l=>{if(o!==this.thumbPreviewSeq||!l)return;let d=this.q(".tpimg"),c=l.width>0?Math.min(1,168/l.width):1;l.width>0?(d.style.cssText=`display:block;width:${l.width*c}px;height:${l.height*c}px;background-image:url("${l.url}");background-position:-${l.x*c}px -${l.y*c}px;background-size:auto;`,d.style.backgroundSize=`${c===1?"auto":`calc(${(c*100).toFixed(2)}%) auto`}`):d.style.cssText=`display:block;width:168px;height:94px;background-image:url("${l.url}");background-size:cover;background-position:center;`})}hideThumbPreview(){this.q(".thumbpreview").hidden=!0}paintScrub(e){this.q(".played").style.width=`${e*100}%`,this.q(".thumb").style.left=`${e*100}%`}onState(e){e==="BUFFERING"&&(this.q(".errorovl").hidden=!0,this.errored=!1);let t=this.q(".buffering"),s=this.q(".ring");e==="BUFFERING"?(t.hidden=!1,s.hidden=!0,this.bufferingTimer===null&&(this.bufferingTimer=window.setTimeout(()=>{s.hidden=!1},250))):(t.hidden=!0,this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)),this.q(".endeddim").hidden=e!=="ENDED",this.syncButtons()}maybeShowOnceOverlays(){let e=this.playerRef,t=e.currentLoadGeneration,s=e.currentItem;if(!s)return;if(t!==this.lastOverlayGeneration){this.lastOverlayGeneration=t,this.overlayTimers.forEach(a=>clearTimeout(a)),this.overlayTimers=[],this.setRatingRow(!1);let r=this.q(".title");r.hidden=!0,r.style.top="12px",this.q(".ratings").hidden=!0}if(this.cfg.showTitle&&s.title&&this.titleShownGeneration!==t){this.titleShownGeneration=t;let r=this.q(".title");r.textContent=s.title,r.hidden=!1,r.style.opacity="1",this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0"},this.cfg.titleTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.titleTimeoutMs+700))}let i=s.contentRatings??[];if(this.cfg.showContentRatings&&i.length>0&&this.ratingsShownGeneration!==t){this.ratingsShownGeneration=t;let r=this.q(".ratings");r.innerHTML=i.map(o=>this.ratingHtml(o)).join(""),r.hidden=!1,r.style.opacity="1",this.setRatingRow(!0),this.overlayTimers.push(window.setTimeout(()=>{r.style.opacity="0",this.setRatingRow(!1)},this.cfg.contentRatingsTimeoutMs)),this.overlayTimers.push(window.setTimeout(()=>{r.hidden=!0},this.cfg.contentRatingsTimeoutMs+700));let a=this.q(".title");a.style.top="53px",this.overlayTimers.push(window.setTimeout(()=>{a.style.top="12px"},this.cfg.contentRatingsTimeoutMs))}}ratingHtml(e){return"age"in e?`<span class="age" style="background:${zg[e.age]}">${jg[e.age]}</span>`:"descriptor"in e?`<span class="desc"><svg viewBox="0 0 24 24" width="16" height="16">${Xg[e.descriptor]??""}</svg></span>`:`<img src="${e.customIconUrl}" alt="">`}setRatingRow(e){this.ratingRowVisible=e,this.q(".topend").style.paddingTop=e?"48px":"8px",this.applyOverlayInsets()}applyOverlayInsets(){let e=this.controlsVisible&&this.ratingRowVisible,t=this.controlsVisible||this.ratingRowVisible,i=Math.min(e?104:t?64:0,this.clientHeight*.5),r=this.controlsVisible?Math.min(68,this.clientHeight*.3):0;for(let a of["top-start","top-center","top-end"]){let o=this.q(`.ovl-${a}`),l=a==="top-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${i}px)`.trim()}for(let a of["bottom-start","bottom-center","bottom-end"]){let o=this.q(`.ovl-${a}`),l=a==="bottom-center"?"translateX(-50%)":"";o.style.transform=`${l} translateY(${-r}px)`.trim()}this.q(".watermark").style.transform=`translateX(-50%) translateY(${this.ratingRowVisible?43:0}px)`}showControls(){this.errored||(this.controlsVisible=!0,this.q(".chrome").hidden=!1,this.applyOverlayInsets(),this.armAutoHide())}hideControls(){this.controlsVisible=!1,this.q(".chrome").hidden=!0,this.closeMenu(),this.applyOverlayInsets()}armAutoHide(){this.cancelAutoHide(),this.playerRef?.isPlaying&&(this.hideTimer=window.setTimeout(()=>{this.openMenu===null&&!this.scrubbing?this.hideControls():this.armAutoHide()},this.cfg.controlsTimeoutMs))}cancelAutoHide(){this.hideTimer!==null&&(clearTimeout(this.hideTimer),this.hideTimer=null)}syncAll(){this.syncButtons(),this.syncProgress(),this.syncWatermark(),this.applyCueSize(),this.applyOverlayInsets()}syncButtons(){let e=this.playerRef,t=this.q(".playpause"),s=e.state==="ENDED"?"replay":e.isPlaying?"pause":"play";t.innerHTML=this.glyph(s,44),t.setAttribute("aria-label",s==="pause"?"Pause":"Play");let i=this.q(".b-volume");i&&(i.innerHTML=this.glyph(e.isMuted||e.volume===0?"volumeMute":"volumeOn",this.dimE.iconSize))}syncProgress(){if(this.scrubbing)return;let e=this.playerRef,t=e.liveInfo,s=this.q(".time");if(t){let i=e.videoElement.seekable;if(i.length>0){let a=i.start(0),o=i.end(i.length-1),l=o>a?(e.videoElement.currentTime-a)/(o-a):1;this.paintScrub(Math.min(1,Math.max(0,l))),this.q(".buffered").style.width="0"}let r=t.latencyMs>12e3?` \u2212${xs(t.latencyMs)}`:"";s.innerHTML=t.atLiveEdge?"":`<b>${r}</b>`}else{let i=e.durationMs,r=i>0?e.currentPositionMs/i:0;this.paintScrub(Math.min(1,r)),this.q(".buffered").style.width=`${i>0?Math.min(100,e.bufferedPositionMs/i*100):0}%`,s.innerHTML=`<b>${xs(e.currentPositionMs)}</b> / ${xs(i)}`,this.paintAdCues(i)}}paintAdCues(e){let t=this.playerRef,s=e>0&&this.cfg.showAdCueMarkers?t.adCuePoints.map(a=>a<0?1:Math.min(1,a*1e3/e)):[],i=s.map(a=>a.toFixed(3)).join(",");if(i===this.lastAdCueKey)return;this.lastAdCueKey=i;let r=this.q(".track");r.querySelectorAll(".cue").forEach(a=>a.remove());for(let a of s){let o=document.createElement("div");o.className="cue",o.style.left=`${a*100}%`,r.appendChild(o)}}syncPeriodic(){let e=this.playerRef;if(e.currentLoadGeneration!==this.lastSeenGeneration){this.lastSeenGeneration=e.currentLoadGeneration,this.q(".errorovl").hidden=!0,this.errored=!1;let c=this.q(".adblocknotice");c.dataset.gen!==String(e.currentLoadGeneration)&&(c.hidden=!0,this.q(".stage").classList.contains("adblocked")&&(this.q(".stage").classList.remove("adblocked"),e.holdPlayback=!1))}this.q(".stage").classList.contains("adblocked")&&e.isPlaying&&e.pause(),this.syncAdUi();let t=`${e.subtitleTextScale}|${e.subtitleStyle.textSizeFraction}|${e.subtitleStyle.foregroundColor}|${e.subtitleStyle.backgroundColor}|${e.subtitleStyle.edgeType}|${e.subtitleStyle.edgeColor}`;t!==this.lastCueKey&&(this.lastCueKey=t,this.applyCueSize());let s=e.liveInfo,i=this.q(".livechip");i.hidden=!s,s&&i.classList.toggle("behind",!s.atLiveEdge);let r=e.currentItem?.streamType??"VOD",a=r!=="LIVE",o=r!=="VOD";this.q(".scrub").hidden=!this.cfg.showProgressBar||!a,this.q(".time").hidden=!this.cfg.showTimeLabels||!a;let l=!this.cfg.showSeekButtons||!a;this.q(".seekback").hidden=l,this.q(".seekfwd").hidden=l;let d=this.root.querySelector(".b-speed");d&&(d.hidden=o||!this.cfg.showSpeedButton)}syncAdUi(){let e=this.playerRef,t=this.q(".stage");t.classList.toggle("adplaying",e.isPlayingAd),t.classList.toggle("adspending",e.adsPending);let s=this.q(".adchrome"),i=this.q(".adtransport"),r=e.adProgress;if(e.isPlayingAd&&r){s.hidden=!1,i.hidden=!1;let a=r.durationMs>0?Math.min(1,r.positionMs/r.durationMs):0;this.q(".adfill").style.width=`${a*100}%`,this.q(".adpod").textContent=r.adCount>1?`${r.adIndex}/${r.adCount}`:"";let o=Math.max(0,Math.ceil((r.durationMs-r.positionMs)/1e3));this.q(".adtime").textContent=`${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`,i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground),i.setAttribute("aria-label",e.adPaused?"Resume ad":"Pause ad")}else s.hidden=!0,i.hidden=!e.isPlayingAd,e.isPlayingAd&&(i.innerHTML=e.adPaused?this.cfg.adPlayIconSvg??wt("play",34,this.col.foreground):this.cfg.adPauseIconSvg??wt("pause",34,this.col.foreground))}syncWatermark(){this.q(".watermark").hidden=this.playerRef?.isLicensed??!1}applyCueSize(){let e=this.playerRef;if(!e)return;let t=this.clientHeight||0,s=Math.max(13,Math.min(t*e.subtitleStyle.textSizeFraction,44))*e.subtitleTextScale,i=e.subtitleStyle,r=i.edgeColor,a=i.edgeType==="OUTLINE"?`text-shadow:-1px -1px 0 ${r},1px -1px 0 ${r},-1px 1px 0 ${r},1px 1px 0 ${r};`:i.edgeType==="DROP_SHADOW"?`text-shadow:2px 2px 3px ${r};`:i.edgeType==="RAISED"?`text-shadow:0 -1px 0 ${r};`:i.edgeType==="DEPRESSED"?`text-shadow:0 1px 0 ${r};`:"";this.q(".cuestyle").textContent=`video::cue { background:${i.backgroundColor}; color:${i.foregroundColor}; font-size:${s.toFixed(1)}px; ${a} }`}enterFullscreen(){return this.requestFullscreen()}exitFullscreen(){document.fullscreenElement===this&&document.exitFullscreen()}toggleFullscreen(){document.fullscreenElement===this?this.cfg.onFullscreenExitRequest?this.cfg.onFullscreenExitRequest():document.exitFullscreen():this.requestFullscreen()}detach(){this.detachFns.forEach(e=>e()),this.detachFns=[],this.overlayTimers.forEach(e=>clearTimeout(e)),this.overlayTimers=[],this.cancelAutoHide(),this.bufferingTimer!==null&&(clearTimeout(this.bufferingTimer),this.bufferingTimer=null)}};function da(){customElements.get("og-player")||customElements.define("og-player",wi)}var Cm="2026-08-19T00:25:00";da();export{nm as DEFAULT_TEXT_SIZE_FRACTION,ue as ErrorCodes,oa as FreewheelAdsProvider,na as ImaAdsProvider,Cm as OGPLAYER_BUILD,am as OGPLAYER_VERSION,ia as OGPlayer,wi as OGPlayerElement,Di as defaultColors,Pd as defaultSubtitleStyle,la as defaultUIConfig,da as defineOGPlayerElement,bs as embeddedDimens,ra as freewheelVmapTagUrl,ki as fullscreenDimens,Wg as hidingAllControls,As as isFreewheelConfig,sa as verifyLicense};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ogplayer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "OGPlayer web SDK — one video player API across Android, iOS and the web.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/ogplayer.js",
|
|
@@ -33,7 +33,20 @@
|
|
|
33
33
|
},
|
|
34
34
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
35
35
|
"homepage": "https://ogplayer.tv",
|
|
36
|
-
"repository": {
|
|
37
|
-
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/ogplayer-sdk/ogplayer-web.git"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"video",
|
|
42
|
+
"player",
|
|
43
|
+
"hls",
|
|
44
|
+
"drm",
|
|
45
|
+
"widevine",
|
|
46
|
+
"fairplay",
|
|
47
|
+
"ima",
|
|
48
|
+
"ads",
|
|
49
|
+
"web-component"
|
|
50
|
+
],
|
|
38
51
|
"author": "OGPlayer (Inverse DOO) <hello@ogplayer.tv>"
|
|
39
52
|
}
|