Closed ricoberger closed 1 year ago
Hi! I have just tried starting the example app, and everything is working fine, including duration.. Would you mind sharing a reproducible example?
Also, can you maybe try logging the contents of the durationStream
to your console and checking if that stream ever gets the expected Duration
value?
If so, the problem may be lying in the implementation of _updatePlaybackState
at media_kit_player.dart#106 where just_audio
may be expecting a non-null duration
value (so I'd need to keep it as a class variable myself, just like _position
or _bufferedPosition
.
Hi, thanks for the fast response. I create a minimal example to reproduce this. The repository can be found here https://github.com/ricoberger/audio-test-app
Here https://github.com/ricoberger/audio-test-app/blob/bdbc7325c4265220310478eea3e8b3f243ca67fb/lib/item_audio_palyer/item_audio_player.dart#L82 it always prints Duration: 0:00:00:000000
.
Thank you for the minimal example, I just ran it and I can confirm the issue.
However, I'll have to take a deeper look tomorrow - though no guarantee on this, as I'm currently busy with school -, as right now it's pretty late here.
I managed to take a look at the issue, and I've isolated the problem to be with just_audio_background
, as if the init
stage is removed from your minimal example, the Duration gets set to its actual value.
I wonder why that is, though, as, like it's stated in the package's README, it is basically a wrapper around audio_service
, which I use myself for my audio player app, without having any issue, though I'm also using AudioHandler.mediaItem.value.duration
's value there as I'm using a custom implementation via audio_service
and that wouldn't be applicable to you...
Either way, I'm only making some suppositions here, I'll investigate further myself into just_audio_background
/audio_service
whenever I'll have more spare time on my hands
Hi @Pato05, thanks for your investigations 🙂. I can confirm that everything is working as expected when the just_audio_background
package is not initialized.
Since the issue is not really related to the just_audio_media_kit
, I will close the issue.
Hi, first of all thanks for your awesome work 🙂
I come across one small issue, it seems that the duration returned by the
durationStream
from theAudioPlayer
is always zero.I'm using nearly the same implementation as in the example for
just_audio
and in the following function the returned duration from the stream is always zero: https://github.com/ryanheise/just_audio/blob/minor/just_audio/example/lib/main.dart#L75-L81Since it is working fine on Android, iOS and macOS, I think the problem might be related to
just_audio_media_kit