Playback Control MPMoviePlayerController

Ok guys, I have a problem. I am a MPMoviePlayerController stream and I want it to play audio in the background and I have achieved that a bit.

This is what I do in mine -didFinishLaunchingWithOptions:

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
    [audioSession setActive:YES error:nil];

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];

      

Now when the app calls -applicationWillResignActive:

I am making a notification to continue playing. And it works, but it's an ugly solution. As there is a second delay between stopping the sound and calling the notification. This way, playback stops for a second and then resumes again, triggering a notification that simply says[viewPlayer play];

And many others have achieved smooth background reproduction. Just like recognition or other apps, when you enter the background, there is no sound or it cuts off the sound. It's really annoying to listen to when I press the home button or lock my phone.

Yes, I have set the background to play.

I also tried -applicationDidEnterBackground:

, but this notification is even slower. This happens after-applicationWillResignActive:

I have no idea how to fix this and how others have achieved this. I've looked at almost all other similar questions. I don't have my problem.

Thanks in advance.

+3


source to share


1 answer







All Articles