Skip to content

Commit

Permalink
refactor: remove media session
Browse files Browse the repository at this point in the history
  • Loading branch information
remvze committed Jan 28, 2024
1 parent 889962b commit 1f63534
Showing 1 changed file with 13 additions and 42 deletions.
55 changes: 13 additions & 42 deletions src/components/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export function App() {
const categories = useMemo(() => sounds.categories, []);

const favorites = useSoundStore(useShallow(state => state.getFavorites()));
const play = useSoundStore(state => state.play);
const pause = useSoundStore(state => state.pause);
const isPlaying = useSoundStore(state => state.isPlaying);

const favoriteSounds = useMemo(() => {
const favoriteSounds = categories
Expand Down Expand Up @@ -56,28 +53,6 @@ export function App() {
return () => document.removeEventListener('visibilitychange', onChange);
}, []);

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) {
navigator.mediaSession.metadata = new MediaMetadata({
title: 'Moodist',
});

navigator.mediaSession.playbackState = 'playing';
} else {
navigator.mediaSession.playbackState = 'paused';
}
}, [isPlaying]);

const allCategories = useMemo(() => {
const favorites = [];

Expand All @@ -94,22 +69,18 @@ export function App() {
}, [favoriteSounds, categories]);

return (
<>
<SnackbarProvider>
<StoreConsumer>
<Container>
<div id="app" />
<Buttons />
<Categories categories={allCategories} />
</Container>

<ScrollToTop />
<Menu />
<SharedModal />
</StoreConsumer>
</SnackbarProvider>

<audio aria-hidden={true} src="" />
</>
<SnackbarProvider>
<StoreConsumer>
<Container>
<div id="app" />
<Buttons />
<Categories categories={allCategories} />
</Container>

<ScrollToTop />
<Menu />
<SharedModal />
</StoreConsumer>
</SnackbarProvider>
);
}

0 comments on commit 1f63534

Please sign in to comment.