audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

getDuration() leads to Fatal error on IOS

Open JohannaShiri opened this issue 2 years ago • 3 comments

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

JohannaShiri avatar Oct 22 '21 18:10 JohannaShiri

Yeah I got this same error

femidof avatar Nov 13 '21 00:11 femidof

Same error here!👋

nicoaudy avatar Jun 09 '22 07:06 nicoaudy

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

PITPL-Maulik-Sinroja avatar Jun 16 '22 06:06 PITPL-Maulik-Sinroja

Maybe relevant for #1284

Gustl22 avatar Sep 27 '22 15:09 Gustl22

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 avatar Sep 27 '22 17:09 JohannaShiri

@JohannaShiri we would be happy, if you provide a fix. We're not able to test on ios / macos, as lacking the needed devices.

Gustl22 avatar Sep 27 '22 18:09 Gustl22