diff --git a/src/components/app/app.tsx b/src/components/app/app.tsx index 5772bf2..5eb5aee 100644 --- a/src/components/app/app.tsx +++ b/src/components/app/app.tsx @@ -86,6 +86,8 @@ export function App() { }, [favoriteSounds, categories]); const audioElement = useRef(null); + + const play = useSoundStore(state => state.play); const isPlaying = useSoundStore(state => state.isPlaying); useEffect(() => { @@ -96,6 +98,16 @@ export function App() { } }, []); + useEffect(() => { + try { + navigator.mediaSession.setActionHandler('play', play); + navigator.mediaSession.setActionHandler('pause', pause); + navigator.mediaSession.setActionHandler('stop', pause); + } catch (error) { + console.log('Media session is no supported yet'); + } + }, [play, pause]); + useEffect(() => { if (isPlaying) { audioElement.current?.play().then(() => {