audioplayers
audioplayers copied to clipboard
getDuration() leads to Fatal error on IOS
This does not happen on Android. Only iOS. Occurs both in release and debug modes, in a simulator and also physical devices.
Steps to reproduce:
var mp3Url = 'https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3';
audioPlayer.setUrl(mp3Url);
audioPlayer.getDuration().then((t) => totalDuration = Duration(milliseconds: t));
Output (and the simulation crashes):
Swift/x86_64-apple-ios-simulator.swiftinterface:33047: Fatal error: Double value cannot be converted to Int because it is either infinite or NaN Lost connection to device.
Running on iPhone 11 iOS 15. audioplayers: ^0.19.1 Flutter version 2.0.5
Yeah I got this same error
Same error here!👋
I got the same error on the iOS device & simulator as well.
But I have identified that there is some configuration mismatch on the audio URL.
First URL - https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3 Open the above URL on the web browser then you have seen the total time duration of audio and running time duration like this - (0:00/6:12)
Second URL - https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3 Then open the above URL on the web browser then you have seen only the running time duration like this - (0:01)
So, when you used the first URL then you can get the total time duration on the code but if you have used the second URL then you can not get the total time duration because in the audio URL there is some misconfiguration audio file (I might be wrong in misconfiguration of audio file URL).
So, when you play the second audio URL on the code then you can get the crash. But if you used the first URL on the same code then you can get the total time duration and you can play the audio file.
Running on iPhone 13 Pro iOS 15.4 audioplayers: ^1.0.0 Flutter version - 2.10.4 Dart - 2.16.2 - DevTools - 2.9.2
Maybe relevant for #1284
I got the same error on the iOS device & simulator as well.
But I have identified that there is some configuration mismatch on the audio URL.
First URL - https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3 Open the above URL on the web browser then you have seen the total time duration of audio and running time duration like this - (0:00/6:12)
Second URL - https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3 Then open the above URL on the web browser then you have seen only the running time duration like this - (0:01)
So, when you used the first URL then you can get the total time duration on the code but if you have used the second URL then you can not get the total time duration because in the audio URL there is some misconfiguration audio file (I might be wrong in misconfiguration of audio file URL).
So, when you play the second audio URL on the code then you can get the crash. But if you used the first URL on the same code then you can get the total time duration and you can play the audio file.
Running on iPhone 13 Pro iOS 15.4 audioplayers: ^1.0.0 Flutter version - 2.10.4 Dart - 2.16.2 - DevTools - 2.9.2
I get it that one of them doesn't have duration. The problem is that the app crashes as a consequence. There should be a null check and then an error without a crash.
@JohannaShiri we would be happy, if you provide a fix. We're not able to test on ios / macos, as lacking the needed devices.