Skip to content

Commit

Permalink
✨ [Website] Pause all audio when interrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi committed Jan 27, 2024
1 parent 798b5c8 commit e80417f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/website/src/store/useEarwurmStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ watch(managerVolumeRef, (incomingVolume) => {
metroInstance.setVolume(manager.volume);
});

document.addEventListener('visibilitychange', () => {
// Pause all playing sounds when the device is interrupted.
if (document.hidden && manager.state === 'interrupted') {
activeStacksRef.value.forEach((stackId) => manager.get(stackId)?.pause());
}
});

export function useEarwurmStore() {
return {
audioLibrary,
Expand Down

0 comments on commit e80417f

Please sign in to comment.