fix player crashing at the end of transcoded track

This commit is contained in:
austinried
2021-08-25 10:24:42 +09:00
parent 75da5d16ac
commit 3db1d795dc
2 changed files with 18 additions and 3 deletions

View File

@@ -64,7 +64,7 @@ export type TrackPlayerSlice = {
netState: 'mobile' | 'wifi'
setNetState: (netState: 'mobile' | 'wifi') => Promise<void>
rebuildQueue: () => Promise<void>
rebuildQueue: (forcePlay?: boolean) => Promise<void>
buildStreamUri: (id: string) => string
resetTrackPlayerState: () => void
@@ -284,7 +284,7 @@ export const createTrackPlayerSlice = (set: SetState<Store>, get: GetState<Store
get().rebuildQueue()
},
rebuildQueue: async () => {
rebuildQueue: async forcePlay => {
return trackPlayerCommands.enqueue(async () => {
const queue = await getQueue()
if (!queue.length) {
@@ -326,7 +326,7 @@ export const createTrackPlayerSlice = (set: SetState<Store>, get: GetState<Store
await TrackPlayer.seekTo(position)
if (state === State.Playing) {
if (state === State.Playing || forcePlay) {
await TrackPlayer.play()
}
})