0
我是新的iOS開發人員。 我正在嘗試使現在播放欄(主屏幕底部欄)中的播放/暫停按鈕模擬我的應用程序中的播放/暫停按鈕。 請任何幫助。iOS AVPlayer問題
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
error:nil];
[[AVAudioSession sharedInstance] setActive:YES
error:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self.player play];
UIBackgroundTaskIdentifier newTaskId = UIBackgroundTaskInvalid;
if([player play]){
newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^(void) {
[[UIApplication sharedApplication] endBackgroundTask: bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
//Your bg code here
[[UIApplication sharedApplication] endBackgroundTask: bgTask];
bgTask = UIBackgroundTaskInvalid;