background-audio

AVAudioPlayer on Lock Screen

跟風遠走 提交于 2019-11-29 03:28:14
问题 I've implemented an audio player using AVAudioPlayer (not AVPlayer ). I'm able to handle the remote control events with the following method. It works quite alright so far, however I see two more subtypes for these events: UIEventSubtypeRemoteControlEndSeekingForward and UIEventSubtypeRemoteControlEndSeekingBackward . - (void)remoteControlReceivedWithEvent:(UIEvent *)event { //if it is a remote control event handle it correctly if (event.type == UIEventTypeRemoteControl) { if (event.subtype =

iOS MPMoviePlayerController playing audio in background

喜夏-厌秋 提交于 2019-11-28 07:52:10
I have MPMoviePlayerController that should play video's audio in background and should be controlled by the multitasking play/pause controls. After updating .plist file with Required background modes and calling the following: - (void)startBackgroundStreaming { [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self becomeFirstResponder]; NSError *activationError = nil; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryPlayback error:&activationError]; [audioSession setActive:YES error:&activationError]; } The