Write the question here.
Is there any way to get the duration of a song if you don't know it ahead of time? I know there's a duration stream for just audio, but how could I use that with the audio service plugin?
I think I just figured a way with custom event streams:
Duration length;
var durationSubscription = _audioPlayer.durationStream.listen((lengthOfSong) {
length = lengthOfSong ?? Duration.zero;
AudioServiceBackground.sendCustomEvent(length);
});
Though there may be a better solution out there.
Thank you for your time.
If you search the FAQ for the word "duration", you will find how the duration can be updated.
So assuming you know how to get the duration from just_audio, which it seems you do, once you have that new duration, you can update it as per the example in the FAQ.
Thank you very much. Yeah I was mostly stuck on getting the duration in the first place, but figured a way to do it not long after I posted. Thank you for your time, again.
That was probably a more appropriate question for the just_audio project I would imagine, in that case since audio_service is only concerned with how to manage the duration once you've got it. But glad you figured it out.
Most helpful comment
That was probably a more appropriate question for the just_audio project I would imagine, in that case since audio_service is only concerned with how to manage the duration once you've got it. But glad you figured it out.