播放音频时,MPMoviePlayerController不会在状态栏中显示播放图标

时间:2012-03-19 14:15:28

标签: ios streaming mpmovieplayercontroller statusbar

我的问题是这样的:我有一个MPMoviePlayerController用于重现流媒体广播,但在播放流媒体时,在状态栏中不会出现播放图标。

有谁知道原因?

1 个答案:

答案 0 :(得分:4)

要允许您的应用控制状态栏中的播放图标,您需要先将AudioSession-Category设置为kAudioSessionCategory_MediaPlayback

UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
                         sizeof (sessionCategory),
                         &sessionCategory);
AudioSessionSetActive (true);

然后注册远程控制事件

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

- (BOOL)canBecomeFirstResponder 
{
    return YES;
}

完成后,不要忘记取消注册

[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
相关问题