2013-02-19 89 views
1

我幾天前問過這個問題,但沒有人回答我,我也找不到解決方案。如何分配AVPlayer播放/暫停按鈕iOS?

所以我想再次問同樣的問題,如果你知道答案請回答我。

我想將圖片中的這些按鈕分配給我的avplayer播放/暫停按鈕。

enter image description here

注:我的應用程序圖標出現在正在播放欄,而不是音樂圖標,我的應用程序在後臺工作正常。

請任何幫助。

回答

2

要允許發送遠程控制事件,必須調用beginReceivingRemoteControlEvents方法UIApplication

然後通過實施remoteControlReceivedWithEvent:方法這樣響應到遠程控制事件:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    ... 

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


    return YES; 
} 

- (void)remoteControlReceivedWithEvent:(UIEvent *)event 
{ 
    switch (event.subtype) 
    { 
     case UIEventSubtypeRemoteControlPlay: 
      // play code 
      ... 
      break; 
     case UIEventSubtypeRemoteControlTogglePlayPause: 
      // toggle code 
      ...  
      break; 
     case UIEventSubtypeRemoteControlNextTrack: 
      // next code 
      ... 
      break; 
     default: 
      break; 
    } 
} 
0

注: 「的設備7.1和以後,使用共享MPRemoteCommandCenter目的是提供一種遠程控制事件註冊您。當使用共享命令中心對象時,不需要調用此方法(注意:beginReceivingRemoteControlEvents)。「 (Source