How to play an audio from URL in flutter?

5,808

assets_audio_player 2.0.7+9 use this music player, Where you can play music from the network as well as from assets folder. And Also you don't need to handle it in the background.

Share:
5,808
Kiranpaul Issac
Author by

Kiranpaul Issac

Updated on December 22, 2022

Comments

  • Kiranpaul Issac
    Kiranpaul Issac over 1 year

    I have tried the following code but it didn't work.

        AudioPlayer _audioPlayer = AudioPlayer();
    
      play() async {
        int result = await _audioPlayer.play('http://thedemos.in/mind/uploads/audio/WjYYX_Namaste2.mp3');
        if (result == 1) {
          setState(() {
            isPlaying = true;
          });
          print('Success');
        }
      }
    
    • Boby
      Boby almost 4 years
      Please share the error message...