@vknext/shared 1.6.33 → 1.6.34
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createPromise as t}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{attachHlsErrorHandlers as
|
|
1
|
+
import{createPromise as t}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{attachHlsErrorHandlers as o}from"./utils/attachHlsErrorHandlers.js";import{extractAudioFromMp4 as a}from"./utils/extractAudioFromMp4.js";import{getHlsInstance as e}from"./utils/getHlsInstance.js";const r=[32,40,48,56,64,80,96,112,128,160,192,224,256,320],s=async({url:s})=>{const{promise:n,resolve:i,reject:d}=t(),l=await e(),u=new l({maxBufferHole:2,maxBufferLength:10,maxBufferSize:5e6,fragLoadingRetryDelay:500,fragLoadingMaxRetry:3,maxFragLookUpTolerance:.2,startPosition:0,enableWorker:!1}),c=new Audio;let m,f,p=null;const E=(t,o)=>{const a=(t=>{const o=r.reduce(((o,a)=>Math.abs(a-t)<Math.abs(o-t)?a:o));return Math.abs(t-o)/o<.15?o:Math.round(t)})(Math.round(8*t/o/1e3));i({bitrate:a,size:t,duration:o}),u.stopLoad(),u.destroy()};return u.on(l.Events.MANIFEST_PARSED,((t,o)=>{const a=o.levels[0]?.details;a&&(f=a.totalduration)})),u.on(l.Events.BUFFER_CODECS,((t,o)=>{o.audio&&"audio/mp4"!==o.audio.container||(m=o.audio)})),u.on(l.Events.BUFFER_APPENDING,((t,o)=>{p=o.data})),u.on(l.Events.FRAG_LOADED,((t,o)=>{if(p){u.detachMedia();const t=m?a(p):p;E(t.length/o.frag.duration*f,f)}})),o({Hls:l,hlsInstance:u,onError:t=>{d(t),u.stopLoad(),u.destroy()}}),u.loadSource(s),u.attachMedia(c),await n};export{s as getTrackDetails};
|