fix(mobile): only take over audio when playback starts #105

Closed
joshuafhiggins wants to merge 1 commits from t3/activate-audio-on-play into main
pull from: t3/activate-audio-on-play
+2 -9
View File
@@ -2,7 +2,6 @@ import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
import {
createAudioPlaylist,
setAudioModeAsync,
setIsAudioActiveAsync,
type AudioMetadata,
type AudioPlaylist,
type AudioPlaylistStatus,
@@ -801,15 +800,9 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
setIsPlayingState(true)
playlist.play()
} else {
// Activating the session here would stop other apps' audio.
// `play()` activates it (iOS) and requests focus (Android).
playlist.pause()
// Enable audio for the restored queue without starting playback.
try {
await setIsAudioActiveAsync(true)
} catch {
if (isCurrentLoad()) {
showError("Audio playback could not be initialized.")
}
}
}
}