audioplayers
audioplayers copied to clipboard
getDuration is returning zero in release mode
_audioPlayer = await AudioCache().play("song.mp3);
_audioDurationMS = await _audioPlayer.getDuration();
print(_audioDurationMS);
The above prints this in debug mode:
I/flutter (31709): 110132
And this in release mode:
I/flutter (31832): 0
If I add a super hacky delay, it works in release mode
_audioPlayer = await AudioCache().play(filename);
// HACK ALERT
await Future.delayed(const Duration(milliseconds: 200));
_audioDurationMS = await _audioPlayer.getDuration();
print(_audioDurationMS);
I/flutter (31970): 110132
Platform: Pixel 4 XL api 31
Any updates on this, I'm also getting this on my pixel 4 device in release mode, _audioPlayer.getDuration();
is always returning zero.
Did you test on audioplayers: ^1.x.x
? See also #1033
I've just tested this on 1.1.0 audioplayers. Still observing issue
Trying to play AAC in m4a container. Randomly duration can be null, but may be not. In debug mode works stable.
@nikitatg did you add the Internet permissions to the AndroidManifest.xml?
Also can you verify / reproduce with our example? Or does it work with an AssetSource
?
@nikitatg did you add the Internet permissions to the AndroidManifest.xml? Also can you verify / reproduce with our example? Or does it work with an
AssetSource
?
Forgot to mention that it happening on desktop platforms: Ubuntu 20 and Windows 10
@Gustl22 for now on yourth example project (with audioplayers v 4.0.1) I see no that issue (Windows platform). For test was used records from android flutter dictaphone (based on package "record"). I will try 4.0.1 on my main project soon
~~I'd like the confirm that this is still happening in v4.01 and v5.0.0 on Linux. I have a similar pattern:~~
await player.setSource(DeviceFileSource(musicPath));
final Duration? dur = await player.getDuration();
~~One third of the time I'm getting the actual duration of my MP3. Another third of the time I'm getting a duration of 0
. And another third of the time dur
is being set to null
.~~
Sorry, I had some improperly structured async code that was causing a false alarm with my app on Linux. my apologies.
This issue is about a version prior 1.x.x. So I'm closing it. It's also very likely that it is the same as #1494 This issue also only is about Android.