Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Song takes really long starting with bluetooth device e.g. Air Pods Pro on network #38

Closed
md186 opened this issue Jun 11, 2020 · 5 comments

Comments

@md186
Copy link

md186 commented Jun 11, 2020

When app is connected to car via Bluetooth or I have my AirPods Pro connected to my iPhone, it takes double of time until song is starting.

It has a similar behaviour to #29
Like I describe there, the following code should make everything on iOS start faster on network:

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

@jeromexiong
Copy link
Owner

@md186 You can modify it locally to test whether it works. Need to modify the file path to
audio_manager/ios/AudioManager.swift
Change 195 lines of file

        queue.play()
        queue.rate = rate

to

        if #available(iOS 10.0, *) {
            queue.playImmediately(atRate: rate)
        } else {
            queue.play()
            queue.rate = rate
        }

You can run it again after editing. Is it effective, hope your feedback

@md186
Copy link
Author

md186 commented Jun 11, 2020

@jeromexiong

Would be nice if you can implement it, im not able to test it my coding experience is not good enough i dont know how to get it working, never did it before..
But in every flutter audio library this was an issue which was solved this way.

if #available(iOS 10.0, *) {
    player?.playImmediately(atRate: 1.0)
} else {
    player?.play()
}

Maybe better define the rate with 1.0? I don't know if its better in your code or no.


Also please do me a favor and check this:

Try to set automaticallyWaitsToMinimizeStalling property of AVPlayer to NO in order to start playback immediately.

_avPlayer = [[AVPlayer alloc]init]; //WithPlayerItem:_avPlayerItem];
_avPlayer.automaticallyWaitsToMinimizeStalling = NO;

But if sufficient content is not available for playing then player might stall.

Apple documentation: https://developer.apple.com/reference/avfoundation/avplayer/1643482-automaticallywaitstominimizestal.

The above code also was something I found on stackoverflow which might be useful for performance on ios network songs.

I'm excited if you put all the stuff in the next plugin version!

@jeromexiong
Copy link
Owner

@md186 fine. You can try the latest version 0.5.5+3

@md186
Copy link
Author

md186 commented Jun 11, 2020

@jeromexiong

It works and its amazingly fast! This task is done now and buffering without wlan now too. It solved both of the problems with the changes from above.

GREAT!! 👍

@md186 md186 closed this as completed Jun 11, 2020
@jeromexiong
Copy link
Owner

jeromexiong commented Jun 11, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants