Skip to content

Commit

Permalink
Fix another issue with resuming audio in browsers.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 4c7270f0657ebc8b5d0a551b986674384dc30f1c
  • Loading branch information
cpojer committed Sep 13, 2024
1 parent df6622c commit 04eaaf8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hera/audio/Music.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export default function useMusic(song: SongName) {
const isPlaying = (video: HTMLVideoElement | null | undefined) =>
video && !video.paused && !video.ended && video.currentTime > 0;

let resume = AudioPlayer.isPaused();
let resume = false;
let timer: ReturnType<typeof setTimeout> | null = null;
const onVisibilityChange = (isVisible: boolean) => {
if (timer != null) {
clearTimeout(timer);
}

if (!App.canQuit) {
if (resume && isVisible) {
if (!document.hidden && resume && isVisible) {
AudioPlayer.resume();
resume = false;
} else if (!isVisible && !AudioPlayer.isPaused()) {
Expand Down

0 comments on commit 04eaaf8

Please sign in to comment.