I am using the audioplayers
package to play my mp3 audio files that are stored in firebase cloud storage. There is a significant delay for both Android and iOS and only just slightly faster in Android. I have since moved all my audio sound files to local asset.
AudioPlayer audioPlayer = AudioPlayer(mode: PlayerMode.LOW_LATENCY);
play(String url) async {
int result = await audioPlayer.play(url);
if (result == 1) {
// success
print('success');
}
}
Just a few days ago, I tested with the audio player in iOS Swift and play some audio files from firebase cloud storage but I did't encounter any significant delay due to buffering and it was a lot faster.
I need to find a way to get around this as I have many audio files and they need to be stored in the network. Anyone of you have encountered similar issues and do you have any good suggestions?
Made this second PR that addresses few shortcomings of the first original PR. Both are merged into master branch of audioplayers.
My PR changes are:
playbackRate
is always used in playImmediatelyAtRate
instead of constant values -- initially set by the library to _defaultPlaybackRate
i.e. 1.0
playImmediatelyAtRate
is added to resume
method as well, not just play
This is the final code that helped solving the audio play delay for the OP:
play
& resume
methodAVPlayer *player = playerInfo[@"player"];
float playbackRate = [playerInfo[@"rate"] floatValue];
if (@available(iOS 10.0, *)) {
[player playImmediatelyAtRate:playbackRate];
} else {
[player play];
}
So calling [player playImmediatelyAtRate:playImmediatelyAtRate:playbackRate]
instead of [player play];
seems to fix the issue.
So far it hasn't been merged into the pub and is still an open the first incomplete PR has been merged, second PR as well.
There's this open pull request that should fix delay on iOS. that hasn't reached release version. Also there's this discussion on big initial lag.