I am trying to add voice message feature on my chat app. I am using record_mp3
package to record voice and audioplayer
to play it. but audioplayer
is not accepting the url. i used this package to play network and asset audio but couldn't found any help to help recorded file.
here is the method i used to record audio
startRecord() async {
recordFilePath = await getFilePath();
RecordMp3.instance.start(recordFilePath, (type) {
setState(() {});
});
setState(() {});
log("recordFilePath $recordFilePath");
}
this is method i am using to play audio
Future<void> play(String url) async {
await _audioPlayer.play(url,);
}
i am getting this error in play function of audioplayer
The argument type 'String' can't be assigned to the parameter type 'Source'.
kindly help how to do this
In play function, you are passing string url directly, but play function expect Source, please check the below example.
AudioPlayer audioPlayer = AudioPlayer();
audioPlayer.play(UrlSource('https://example.com/my-audio.wav'));