-
-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Is your feature request related to a problem? Please describe.
Devs should definetly check that the URL provided when creating an AudioItem is valid and can be played. But there remains a case where the url can be broken later on, or it was never available. When this happens in a QueuedAudioPlayer it stops playing, I think a better solution is to skip to the next AudioItem in the queue.
Describe the solution or feature you would like
I've been playing around with a solution for this, and came up with the following code. I placed it inside the handleAudioPlayerPlaybackEnd handler, but I'm not sure if that's the right approach.
if let currentItem = audioManager.player.currentItem {
let currentPath = URL(string: currentItem.getSourceUrl())!.path()
let doesNotExist = !FileManager.default.fileExists(atPath: currentPath)
if doesNotExist {
print("File DOES NOT EXIST")
switch data {
case .failed:
let newIndex = audioManager.player.currentIndex + 1
try? audioManager.player.jumpToItem(atIndex: newIndex)
case .skippedToPrevious:
let newIndex = audioManager.player.currentIndex - 1
try? audioManager.player.jumpToItem(atIndex: newIndex)
default: break
}
}
}
Describe alternatives you've considered
I have not thought of any alternatives, but any feedback on this is welcomed.
bsneed
Metadata
Metadata
Assignees
Labels
No labels