vidply 1.0.30 → 1.0.32

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.
@@ -104,12 +104,12 @@
104
104
  "format": "esm"
105
105
  },
106
106
  "src/utils/VideoFrameCapture.js": {
107
- "bytes": 4092,
107
+ "bytes": 4640,
108
108
  "imports": [],
109
109
  "format": "esm"
110
110
  },
111
111
  "src/controls/ControlBar.js": {
112
- "bytes": 138319,
112
+ "bytes": 145861,
113
113
  "imports": [
114
114
  {
115
115
  "path": "src/utils/DOMUtils.js",
@@ -352,7 +352,7 @@
352
352
  "format": "esm"
353
353
  },
354
354
  "src/renderers/HLSRenderer.js": {
355
- "bytes": 9900,
355
+ "bytes": 10310,
356
356
  "imports": [
357
357
  {
358
358
  "path": "src/renderers/HTML5Renderer.js",
@@ -368,7 +368,7 @@
368
368
  "format": "esm"
369
369
  },
370
370
  "src/core/Player.js": {
371
- "bytes": 209146,
371
+ "bytes": 214379,
372
372
  "imports": [
373
373
  {
374
374
  "path": "src/utils/EventEmitter.js",
@@ -484,7 +484,7 @@
484
484
  "format": "esm"
485
485
  },
486
486
  "src/features/PlaylistManager.js": {
487
- "bytes": 48411,
487
+ "bytes": 49922,
488
488
  "imports": [
489
489
  {
490
490
  "path": "src/utils/DOMUtils.js",
@@ -600,7 +600,7 @@
600
600
  "bytesInOutput": 4651
601
601
  },
602
602
  "src/renderers/HLSRenderer.js": {
603
- "bytesInOutput": 5898
603
+ "bytesInOutput": 6010
604
604
  },
605
605
  "src/renderers/SoundCloudRenderer.js": {
606
606
  "bytesInOutput": 5597
@@ -609,16 +609,16 @@
609
609
  "bytesInOutput": 437
610
610
  },
611
611
  "src/core/Player.js": {
612
- "bytesInOutput": 77401
612
+ "bytesInOutput": 77444
613
613
  },
614
614
  "src/controls/ControlBar.js": {
615
- "bytesInOutput": 61316
615
+ "bytesInOutput": 64315
616
616
  },
617
617
  "src/utils/PerformanceUtils.js": {
618
618
  "bytesInOutput": 257
619
619
  },
620
620
  "src/utils/VideoFrameCapture.js": {
621
- "bytesInOutput": 842
621
+ "bytesInOutput": 1013
622
622
  },
623
623
  "src/controls/CaptionManager.js": {
624
624
  "bytesInOutput": 7462
@@ -639,7 +639,7 @@
639
639
  "bytesInOutput": 1877
640
640
  }
641
641
  },
642
- "bytes": 346259
642
+ "bytes": 349584
643
643
  }
644
644
  }
645
645
  }
@@ -3,4 +3,4 @@
3
3
  * (c) 2025 Matthias Peltzer
4
4
  * Released under GPL-2.0-or-later License
5
5
  */
6
- var s=class{constructor(e){this.player=e,this.media=e.element,this.hls=null}async init(){this.canPlayNatively()?(this.player.log("Using native HLS support"),await this.initNative()):(this.player.log("Using hls.js for HLS support"),await this.initHlsJs())}canPlayNatively(){let e=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),t=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;return!e&&!t?!1:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}async initNative(){let e=(await import("./vidply.HTML5Renderer-KKW3OLHM.min.js")).HTML5Renderer,t=new e(this.player);await t.init(),Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(i=>{i!=="constructor"&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))})}async initHlsJs(){if(this.media.controls=!1,this.media.removeAttribute("controls"),window.Hls||await this.loadHlsJs(),!window.Hls.isSupported())throw new Error("HLS is not supported in this browser");this.hls=new window.Hls({debug:this.player.options.debug,enableWorker:!0,lowLatencyMode:!1,backBufferLength:90,maxBufferLength:30,maxMaxBufferLength:600,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:4,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3}),this.hls.attachMedia(this.media);let e=this.player.currentSource;if(!e){let t=this.player.element.querySelector("source");t?e=t.getAttribute("src"):e=this.player.element.getAttribute("src")||this.player.element.src}if(this.player.log(`Loading HLS source: ${e}`,"log"),!e)throw new Error("No HLS source found");this.hls.loadSource(e),this.attachHlsEvents(),this.attachMediaEvents()}async loadHlsJs(){return new Promise((e,t)=>{let i=document.createElement("script");i.src="https://cdn.jsdelivr.net/npm/hls.js@latest",i.onload=()=>e(),i.onerror=()=>t(new Error("Failed to load hls.js")),document.head.appendChild(i)})}attachHlsEvents(){this.hls.on(window.Hls.Events.MANIFEST_PARSED,(e,t)=>{this.player.log("HLS manifest loaded, found "+t.levels.length+" quality levels"),this.player.emit("hlsmanifestparsed",t),this.player.container&&this.player.container.classList.remove("vidply-external-controls")}),this.hls.on(window.Hls.Events.LEVEL_SWITCHED,(e,t)=>{this.player.log("HLS level switched to "+t.level),this.player.emit("hlslevelswitched",t)}),this.hls.on(window.Hls.Events.ERROR,(e,t)=>{this.handleHlsError(t)}),this.hls.on(window.Hls.Events.FRAG_BUFFERED,()=>{this.player.state.buffering=!1})}attachMediaEvents(){this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume)}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.media.addEventListener("error",()=>{this.player.handleError(this.media.error)})}handleHlsError(e){if(this.player.log(`HLS Error - Type: ${e.type}, Details: ${e.details}, Fatal: ${e.fatal}`,"warn"),e.response&&this.player.log(`Response code: ${e.response.code}, URL: ${e.response.url}`,"warn"),e.fatal)switch(e.type){case window.Hls.ErrorTypes.NETWORK_ERROR:this.player.log("Fatal network error, trying to recover...","error"),this.player.log(`Network error details: ${e.details}`,"error"),setTimeout(()=>{this.hls.startLoad()},1e3);break;case window.Hls.ErrorTypes.MEDIA_ERROR:this.player.log("Fatal media error, trying to recover...","error"),this.hls.recoverMediaError();break;default:this.player.log("Fatal error, cannot recover","error"),this.player.handleError(new Error(`HLS Error: ${e.type} - ${e.details}`)),this.hls.destroy();break}else this.player.log("Non-fatal HLS error: "+e.details,"warn")}play(){let e=window.scrollX,t=window.scrollY,i=this.media.play();window.scrollTo(e,t),i!==void 0&&i.catch(r=>{this.player.log("Play failed:",r,"warn")})}pause(){this.media.pause()}seek(e){this.media.currentTime=e}setVolume(e){this.media.volume=e}setMuted(e){this.media.muted=e}setPlaybackSpeed(e){this.media.playbackRate=e}switchQuality(e){this.hls&&(this.hls.currentLevel=e)}getQualities(){return this.hls&&this.hls.levels?this.hls.levels.map((e,t)=>({index:t,height:e.height,width:e.width,bitrate:e.bitrate,name:`${e.height}p`})):[]}getCurrentQuality(){return this.hls?this.hls.currentLevel:-1}destroy(){this.hls&&(this.hls.destroy(),this.hls=null)}};export{s as HLSRenderer};
6
+ var a=class{constructor(e){this.player=e,this.media=e.element,this.hls=null}async init(){this.canPlayNatively()?(this.player.log("Using native HLS support"),await this.initNative()):(this.player.log("Using hls.js for HLS support"),await this.initHlsJs())}canPlayNatively(){let e=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),t=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;return!e&&!t?!1:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}async initNative(){let e=(await import("./vidply.HTML5Renderer-KKW3OLHM.min.js")).HTML5Renderer,t=new e(this.player);await t.init(),Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(i=>{i!=="constructor"&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))})}async initHlsJs(){if(this.media.controls=!1,this.media.removeAttribute("controls"),window.Hls||await this.loadHlsJs(),!window.Hls.isSupported())throw new Error("HLS is not supported in this browser");this.hls=new window.Hls({debug:this.player.options.debug,enableWorker:!0,lowLatencyMode:!1,backBufferLength:90,maxBufferLength:30,maxMaxBufferLength:600,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:4,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3}),this.hls.attachMedia(this.media);let e=this.player.currentSource;if(!e){let t=this.player.element.querySelector("source");t?e=t.getAttribute("src"):e=this.player.element.getAttribute("src")||this.player.element.src}if(this.player.log(`Loading HLS source: ${e}`,"log"),!e)throw new Error("No HLS source found");this.hls.loadSource(e),this.attachHlsEvents(),this.attachMediaEvents()}async loadHlsJs(){return new Promise((e,t)=>{let i=document.createElement("script");i.src="https://cdn.jsdelivr.net/npm/hls.js@latest",i.onload=()=>e(),i.onerror=()=>t(new Error("Failed to load hls.js")),document.head.appendChild(i)})}attachHlsEvents(){this.hls.on(window.Hls.Events.MANIFEST_PARSED,(e,t)=>{this.player.log("HLS manifest loaded, found "+t.levels.length+" quality levels"),this.player.emit("hlsmanifestparsed",t),this.player.container&&this.player.container.classList.remove("vidply-external-controls")}),this.hls.on(window.Hls.Events.LEVEL_SWITCHED,(e,t)=>{this.player.log("HLS level switched to "+t.level),this.player.emit("hlslevelswitched",t)}),this.hls.on(window.Hls.Events.ERROR,(e,t)=>{this.handleHlsError(t)}),this.hls.on(window.Hls.Events.FRAG_BUFFERED,()=>{this.player.state.buffering=!1})}attachMediaEvents(){this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume)}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.media.addEventListener("error",()=>{this.player.handleError(this.media.error)})}handleHlsError(e){if(this.player.log(`HLS Error - Type: ${e.type}, Details: ${e.details}, Fatal: ${e.fatal}`,"warn"),e.response&&this.player.log(`Response code: ${e.response.code}, URL: ${e.response.url}`,"warn"),e.fatal)switch(e.type){case window.Hls.ErrorTypes.NETWORK_ERROR:this.player.log("Fatal network error, trying to recover...","error"),this.player.log(`Network error details: ${e.details}`,"error"),setTimeout(()=>{this.hls.startLoad()},1e3);break;case window.Hls.ErrorTypes.MEDIA_ERROR:this.player.log("Fatal media error, trying to recover...","error"),this.hls.recoverMediaError();break;default:this.player.log("Fatal error, cannot recover","error"),this.player.handleError(new Error(`HLS Error: ${e.type} - ${e.details}`)),this.hls.destroy();break}else this.player.log("Non-fatal HLS error: "+e.details,"warn")}play(){let e=window.scrollX,t=window.scrollY,i=this.media.play();window.scrollTo(e,t),i!==void 0&&i.catch(s=>{this.player.log("Play failed:",s,"warn")})}pause(){this.media.pause()}seek(e){this.media.currentTime=e}setVolume(e){this.media.volume=e}setMuted(e){this.media.muted=e}setPlaybackSpeed(e){this.media.playbackRate=e}switchQuality(e){this.hls&&(this.hls.currentLevel=e)}getQualities(){return this.hls&&this.hls.levels?this.hls.levels.map((e,t)=>{let i=Number(e.height)||0,s=Number(e.bitrate)||0,r=s>0?Math.round(s/1e3):0,l=i>0?`${i}p`:r>0?`${r} kb`:"Auto";return{index:t,height:e.height,width:e.width,bitrate:e.bitrate,name:l}}):[]}getCurrentQuality(){return this.hls?this.hls.currentLevel:-1}destroy(){this.hls&&(this.hls.destroy(),this.hls=null)}};export{a as HLSRenderer};