@mediafox/react 1.2.10 → 1.2.12
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/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var H=((L)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(L,{get:(M,q)=>(typeof require<"u"?require:M)[q]}):L)(function(L){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+L+'" is not supported')});import{useCallback as F,useEffect as W,useMemo as c,useRef as J,useSyncExternalStore as g}from"react";function f(L={}){let M=J(null),q=J(null),B=J(new Set),K=c(()=>({renderTarget:L.renderTarget,audioContext:L.audioContext,volume:L.volume,muted:L.muted,playbackRate:L.playbackRate,autoplay:L.autoplay,preload:L.preload,crossOrigin:L.crossOrigin,maxCacheSize:L.maxCacheSize,renderer:L.renderer}),[L.renderTarget,L.audioContext,L.volume,L.muted,L.playbackRate,L.autoplay,L.preload,L.crossOrigin,L.maxCacheSize,L.renderer]);W(()=>{import("@mediafox/core").then(({MediaFox:D})=>{let I=new D(K);M.current=I;let U=I.subscribe((Q)=>{q.current=Q;for(let V of B.current)V()});q.current=I.getState();for(let Q of B.current)Q();return()=>{U.unsubscribe(),I.destroy(),M.current=null,q.current=null}})},[K]),W(()=>{let D=M.current;if(!D)return;let I=[],U=(Q,V)=>{if(V)D.on(Q,V),I.push([Q,V])};return U("loadstart",L.onLoadStart),U("loadedmetadata",L.onLoadedMetadata),U("loadeddata",L.onLoadedData),U("canplay",L.onCanPlay),U("canplaythrough",L.onCanPlayThrough),U("play",L.onPlay),U("pause",L.onPause),U("playing",L.onPlaying),U("ended",L.onEnded),U("timeupdate",L.onTimeUpdate),U("durationchange",L.onDurationChange),U("volumechange",L.onVolumeChange),U("ratechange",L.onRateChange),U("seeking",L.onSeeking),U("seeked",L.onSeeked),U("waiting",L.onWaiting),U("progress",L.onProgress),U("error",L.onError),U("warning",L.onWarning),U("trackchange",L.onTrackChange),U("statechange",L.onStateChange),U("rendererchange",L.onRendererChange),U("rendererfallback",L.onRendererFallback),U("playlistchange",L.onPlaylistChange),U("playlistitemchange",L.onPlaylistItemChange),U("playlistend",L.onPlaylistEnd),U("playlistadd",L.onPlaylistAdd),U("playlistremove",L.onPlaylistRemove),U("playlistitemerror",L.onPlaylistItemError),()=>{for(let[Q,V]of I)D.off(Q,V)}},[L.onLoadStart,L.onLoadedMetadata,L.onLoadedData,L.onCanPlay,L.onCanPlayThrough,L.onPlay,L.onPause,L.onPlaying,L.onEnded,L.onTimeUpdate,L.onDurationChange,L.onVolumeChange,L.onRateChange,L.onSeeking,L.onSeeked,L.onWaiting,L.onProgress,L.onError,L.onWarning,L.onTrackChange,L.onStateChange,L.onRendererChange,L.onRendererFallback,L.onPlaylistChange,L.onPlaylistItemChange,L.onPlaylistEnd,L.onPlaylistAdd,L.onPlaylistRemove,L.onPlaylistItemError]);let X=F((D)=>{return B.current.add(D),()=>{B.current.delete(D)}},[]),N=F(()=>q.current,[]),A=g(X,N,N),Y=F(async(D,I)=>{if(!M.current)throw Error("Player not initialized");return M.current.load(D,I)},[]),Z=F(async()=>{if(!M.current)throw Error("Player not initialized");return M.current.play()},[]),_=F(()=>{if(!M.current)throw Error("Player not initialized");M.current.pause()},[]),$=F(async(D,I)=>{if(!M.current)throw Error("Player not initialized");return M.current.seek(D,I)},[]),j=F(async()=>{if(!M.current)throw Error("Player not initialized");return M.current.stop()},[]),z=F(async(D)=>{if(!M.current)throw Error("Player not initialized");return M.current.screenshot(D)},[]),P=F(async(D)=>{if(!M.current)throw Error("Player not initialized");return M.current.setRenderTarget(D)},[]),E=F(async(D)=>{if(!M.current)throw Error("Player not initialized");return M.current.switchRenderer(D)},[]),O=F(async(D,I)=>{if(!M.current)throw Error("Player not initialized");return M.current.loadPlaylist(D,I)},[]),w=F((D,I)=>{if(!M.current)throw Error("Player not initialized");M.current.addToPlaylist(D,I)},[]),v=F(async(D)=>{if(!M.current)throw Error("Player not initialized");return M.current.removeFromPlaylist(D)},[]),x=F(()=>{if(!M.current)throw Error("Player not initialized");M.current.clearPlaylist()},[]),S=F(async()=>{if(!M.current)throw Error("Player not initialized");return M.current.next()},[]),m=F(async()=>{if(!M.current)throw Error("Player not initialized");return M.current.prev()},[]),k=F(async(D)=>{if(!M.current)throw Error("Player not initialized");return M.current.jumpTo(D)},[]),h=F((D)=>{if(!M.current)throw Error("Player not initialized");M.current.playlistMode=D},[]),C=A?.rendererType??null,T=A?.playlist??[],G=A?.currentPlaylistIndex??null,u=G!==null?T[G]??null:null,b=A?.playlistMode??null;return{player:M.current,state:A,load:Y,play:Z,pause:_,seek:$,stop:j,screenshot:z,setRenderTarget:P,switchRenderer:E,rendererType:C,loadPlaylist:O,addToPlaylist:w,removeFromPlaylist:v,clearPlaylist:x,next:S,prev:m,jumpTo:k,setPlaylistMode:h,playlist:T,playlistIndex:G,nowPlaying:u,playlistMode:b}}export{f as useMediaFox};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediafox/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "React hooks for MediaFox media player",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@mediafox/core": "^1.2.
|
|
34
|
+
"@mediafox/core": "^1.2.12",
|
|
35
35
|
"react": ">=18.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|