Compare commits

..
2 changed files with 5 additions and 21 deletions

No files matched your search

+5 -20
View File
@@ -2,7 +2,6 @@ import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
import {
createAudioPlaylist,
setAudioModeAsync,
setIsAudioActiveAsync,
type AudioMetadata,
type AudioPlaylist,
type AudioPlaylistStatus,
@@ -376,8 +375,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
const handlePlaylistStatusUpdate = useCallback(
(status: AudioPlaylistStatus) => {
// iOS may remove the finished item before delivering its final status.
if (!status.isLoaded && !status.didJustFinish) return
if (!status.isLoaded) return
const state = storeRef.current.getState()
if (loadedSongIdsRef.current[status.currentIndex] !== state.queue[0]) {
return
@@ -428,14 +426,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
isPlayingRef.current = false
setIsPlayingState(false)
storeRef.current.update(playbackQueue.skipNext)
const playlist = playlistRef.current
if (playlist) {
playlist.pause()
// Reload the final item, which iOS removes when playback ends.
ignoreTrackChangeRef.current = true
playlist.skipTo(status.currentIndex)
scheduleTrackChangeHandling()
}
void playlistRef.current?.seekTo(0)
currentTimeRef.current = 0
setCurrentTime(0)
return
@@ -451,7 +442,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
playlist?.play()
}
},
[scheduleTrackChangeHandling]
[]
)
const handleTrackChanged = useCallback(
@@ -809,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.")
}
}
}
}
@@ -955,7 +955,6 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
if (!shouldContinuePlaying) {
autoPlayNextRef.current = false
isPlayingRef.current = false
audio.pause()
audio.currentTime = 0
currentTimeRef.current = 0
setCurrentTime(0)