Open mt633 opened 1 year ago
As a workaround, I've added some code here to pass the error through to the Flutter error handler instead which allows me to retry the playback and it seems like it always works the second time:
case .failed:
debugPrint("playback failed")
if (item.error is URLError && (item.error as! URLError).code == URLError.unsupportedURL) {
self?.onError(AssetAudioPlayerError(type: "url", message: "avplayer error"))
return
}
And on the Flutter side, something like this.
player.onErrorDo = (handler) {
if (errorCount < 3) {
handler.player.open(
handler.playlist!.copyWith(startIndex: handler.playlistIndex),
seek: handler.currentPosition);
errorCount++;
} else {
// TODO: Handle errors not solved by retrying
}
};
Flutter Version
My version : 3.3.1
Lib Version
My version : 3.0.6
Platform (Android / iOS / web) + version
Platform : iOS 16.2
Describe the bug
We provide HLS content (not live) and while testing the library I discovered that some files sometimes fail.
The error code is -1002 which means it is an unsupported URL. The URL which it fails with is in itself OK (it looks something like this:
https://mydomain.com/stream/audio4/master.m3u8
) and works if I test it manually.The file contents look like this:
In other words, there are two different streams based on bandwidth with two different index files stored in the same directory.
When I enabled
CFNETWORK_DIAGNOSTICS
I discovered that it somewhere fails to add the full path to the index fileIn other words, it tries to open
index_0.m3u8
as the URL instead ofhttps://[full-path-to-server-from-previous-file]/index_0.m3u8
. Given that it works 4 out of 5 times with this library, this is a very strange behavior.My question is if the HLS is processed by this library and therefore is a bug that should be solved here or is that handled by native Apple code? I have searched the web but so far no success in finding similar issues.
Small code to reproduce