mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-05-25 07:45:56 +00:00
fix(web): fix container warning and store lifecycle
This commit is contained in:
@@ -61,6 +61,11 @@ class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
|
||||
this.mediaSession?.disable();
|
||||
(this.eventEmitter as WebEventEmitter).destroy();
|
||||
this.clearAllEvents();
|
||||
// Store destroy calls detach internally — safe here since player is dead
|
||||
if (this._store?.destroyed === false) {
|
||||
this._store.destroy();
|
||||
}
|
||||
this._store = null;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -21,13 +21,15 @@ const Player = createPlayer({ features: videoFeatures });
|
||||
* then passes the ready store to the adapter.
|
||||
*/
|
||||
function PlayerBridge({ player }: { player: VideoPlayer }) {
|
||||
const { store } = usePlayerContext();
|
||||
const { store, container } = usePlayerContext();
|
||||
const setMedia = useMediaAttach();
|
||||
|
||||
useEffect(() => {
|
||||
if (!container) return;
|
||||
|
||||
const video = player.__getMedia();
|
||||
setMedia?.(video);
|
||||
const detach = store.attach({ media: video, container: null });
|
||||
const detach = store.attach({ media: video, container });
|
||||
player.__setStore(store);
|
||||
|
||||
return () => {
|
||||
@@ -35,7 +37,7 @@ function PlayerBridge({ player }: { player: VideoPlayer }) {
|
||||
detach?.();
|
||||
setMedia?.(null);
|
||||
};
|
||||
}, [store, player, setMedia]);
|
||||
}, [store, player, setMedia, container]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user