Search code examples
flutterdartjust-audio

Play audio from specific time duration flutter


I am developing flutter application that plays audio. normally audio starts from 0 seconds but if already listened 30 seconds then by re playing it should starts from 30 second onwards. I have used audioPlayer.seek() but only slider and timer updates but audio still starts from begin.


Solution

  • hmm. I think you're going to need to include some code before it'd be possible to tell what's going on. However, one thought is that I don't think you can seek until you've loaded the audio - if you don't load it independently and just call play(), I think you'd have to switch to loading before calling play.

    That'd be something like this:

    await player.setAudioSource(source);
    await player.load();
    await player.seek(Duration(seconds:30);
    await player.play();