i am trying to play an audio via url in flutter. I'm using the audioplayers library: ^0.20.1, from the logs there seems to be no problems but I don't hear the audio coming out.
AudioPlayer audio = AudioPlayer(); audio.play(myUrl)
I assumed it was a permissions issue but it doesn't solve anything anyway
await Permission.audio.request();
if(await Permission.audio.isGranted)
{
AudioPlayer audio = AudioPlayer();
audio.play(myUrl);
}
use latest version of audio player package audioplayers: ^3.0.1
Follow these steps:
final player = AudioPlayer();
await player.setSourceUrl(url); // equivalent to setSource(UrlSource(url));
if you want to set the url and start playing, using the play shortcut:
await player.play(DeviceFileSource(localFile)); // will immediately start playing
For more info see the documentation