2

We develop a cross platform multimedia player. It uses OpenAL for playing audio. On iOS we want to use functionality of the MPNowPlayingInfoCenter and Remote Control Events.

Setting current position, elapsed time, other track info works well. But, unfortunately, when pressing the pause button in the info center player pauses, but the pause button does not change its status. Info center continues showing that playback isn't paused (time labels continue counting).

We handle the UIEventSubtypeRemoteControlPause event in this way:

[self.player pause]; // Pause playback

// Update MPNowPlayingInfoCenter
NSMutableDictionary *mediaInformation = [NSMutableDictionary dictionaryWithDictionary:[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo];
mediaInformation[MPNowPlayingInfoPropertyPlaybackRate] = @0.0;
mediaInformation[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @(self.player.currentTime);
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = mediaInformation;

Does MPNowPlayingInfoCenter support playing audio through OpenAL or we missed something.

double-beep
  • 5,031
  • 17
  • 33
  • 41
bartl
  • 392
  • 2
  • 11

1 Answers1

0

I had the same problem, and it turned out not to be related to OpenAL after all, but the playback category of AVAudioSession, see this stack overflow post: Is MPNowPlayingInfoCenter compatible with AVAudioPlayer?.

I set the correct category with the following code:

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];

I initially used withOptions: AVAudioSessionCategoryOptionMixWithOthers together with setCategory:AVAudioSessionCategoryPlayback, and it caused the lock screen playback controls not to work.

Community
  • 1
  • 1
vatte
  • 1
  • 1