@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 e}from"./utils/attachHlsErrorHandlers.js";import{getHlsInstance as o}from"./utils/getHlsInstance.js";const r=[32,40,48,56,64,80,96,112,128,160,192,224,256,320],n=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0],a=[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0],i=async({url:i})=>{const{promise:s,resolve:l,reject:u}=t(),c=await o(),f=new c({maxBufferHole:2,maxBufferLength:10,maxBufferSize:5e6,fragLoadingRetryDelay:500,fragLoadingMaxRetry:3,maxFragLookUpTolerance:.2,startPosition:0,enableWorker:!1}),d=new Audio;let m;return f.on(c.Events.MANIFEST_PARSED,((t,e)=>{const o=e.levels[0]?.details;o&&(m=o.totalduration)})),f.on(c.Events.FRAG_LOADED,((t,{frag:e,payload:o})=>{if("initSegment"===e.sn)return;let i=(t=>{const e=Math.min(Math.max(0,t.length-4),102400);for(let o=0;o<e;o++){if(255!==t[o])continue;const e=t[o+1],r=t[o+2];if(void 0===e||void 0===r)continue;if(224&~e)continue;const i=(24&e)>>3;if(1===i)continue;if(1!=(6&e)>>1)continue;const s=(240&r)>>4;if(0===s||15===s)continue;const l=(3===i?n:a)[s];if(l&&l>0)return l}return null})(new Uint8Array(o));if(!i)if(e.bitrate){i=(t=>{const e=r.reduce(((e,o)=>Math.abs(o-t)<Math.abs(e-t)?o:e));return Math.abs(t-e)/e<.15?e:Math.round(t)})(e.bitrate/1e3)}else i=0;const s=m||e.duration,u=1e3*i*s/8;l({bitrate:i,size:Math.round(u),duration:s}),f.stopLoad(),f.destroy()})),e({Hls:c,hlsInstance:f,onError:t=>{u(t),f.stopLoad(),f.destroy()}}),f.loadSource(i),f.attachMedia(d),await s};export{i as getTrackDetails};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vknext/shared",
3
- "version": "1.6.33",
3
+ "version": "1.6.34",
4
4
  "description": "vk next shared",
5
5
  "type": "module",
6
6
  "files": [