Search code examples
fluttermp3audio-streamingjust-audiofile-saver

how to record audio from a URL (podcast, radio, stream) into file without using mic. Flutter plugin Just Audio


I have a radio app where I play radio from URL using just audio in flutter (by using seturl() method and then play() method). I want to record audio using stream or some sort of other way than using microphone (which is already done and working). Thanks.

And I need to save file as mp3.

I wonder maybe there is a stream which I can listen to get streaming audio as uint8list to save in file. Or any other way then recording with microphone.


Solution

  • You can simply do this by reading audio stream as bytes then write these bytes to a file.

    First import dio repo to handle reading audio stream as Stream of bytes.

    Check Dio Package

    then add this class to your project .. copy it from my gist

    Record Class

    and simply use it by

    Start recording:

    Record.start('stream url);
    

    Stop recording:

    Record.stop();