Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play an audio from URL in flutter?

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');
    }
  }
like image 460
Kiranpaul Issac Avatar asked Sep 06 '25 00:09

Kiranpaul Issac


1 Answers

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.

like image 185
Deepak Ror Avatar answered Sep 09 '25 00:09

Deepak Ror