jeromexiong / audio_manager

A flutter plugin for music playback, including notification handling.
MIT License
100 stars 53 forks source link

Buffering Songs on iOS not working immediately #29

Closed md186 closed 4 years ago

md186 commented 4 years ago

Hello, buffering on iOS with WLAN off is not working as expected. (Please check it on android too) I tested it on several real iPhones, if WLAN is off and I use LTE or other mobile network, song starts playing first, when complete song is initialized, and then it starts buffering at very last. This causes waiting for song start playing very long time. It is wrong order. If wlan is on, song directly starts playing and buffering like it should

Please fix this on WLAN off mode, this is really annoying. Thank you!

jeromexiong commented 4 years ago

hi,guys,I test the buffering loading locally. Whether WLAN or LTE, it can be buffering normally. Even if the network is switched in the buffer, it will still be loaded. Have you tried to change the audio url?

md186 commented 4 years ago

Hello thank you for checking, I’m using your plugin in my app, with wlan everything is working fine the queue is:

loading list -> loading selected song and playing and buffering at the same time. It’s playing and buffering together.

Without wlan it is the following:

Loading list -> loading selected song until the complete song is loaded -> then after loading it starts playing first when buffering is starting. It starts playing later.

Buffering and playing song at the same time is only working with wlan on. With wlan of it waits until the complete song is loaded and THEN it starts buffering and after that it starts playing at the very end.

I have only network songs in the list no local Songs. Maybe that’s the issue.

md186 commented 4 years ago

@jeromexiong

well after some research it seems like other mediaplayer plugin library creators did have the same issue called iOS buffering not working. It waits to download the file.

In general starting network song is slightly slower than on android player. They fixed it with the following code here. Please implement it to make the player on iOS much more faster:

AVPlayer *player = playerInfo[@"player"];

float playbackRate = [playerInfo[@"rate"] floatValue];

if (@available(iOS 10.0, *)) {
    [player playImmediatelyAtRate:playbackRate];
} else {
    [player play];
}

Apple dev documentation: https://developer.apple.com/documentation/avfoundation/avplayer/1643480-playimmediatelyatrate?language=objc

md186 commented 4 years ago

Closed since @jeromexiong fixed it with playImmediatelyAtRate and automaticallyWaitsToMinimizeStalling

Playing network songs on ios with wlan or lte or whatever is super fast now ! 👌

jeromexiong commented 4 years ago

enjoy your job 🎉