1

我正在使用AVPlayer可以通过双击主页按钮或技术术语来控制播放、暂停功能的地方remoteControlledEvents。我想知道如何实现它,这样我就可以进入remoteControlledEvents.

谢谢

-(void)remoteControlReceivedWithEvent:(UIEvent *)event {
  switch (event.subtype) {
    case UIEventSubtypeRemoteControlTogglePlayPause:
      if (avplayer.rate == 0.0) {
        [avplayer play];
      } else {
        [avplayer pause];
      }
      break;
    case UIEventSubtypeRemoteControlPlay:
      [avplayer play];
      break;
    case UIEventSubtypeRemoteControlPause:
      [avplayer pause];
      break;

  }
}
4

1 回答 1

1

AVPlayer用下一首歌制作一个新的并告诉它播放。

该事件是UIEventSubtypeRemoteControlNextTrack

case: UIEventSubtypeRemoteControlNextTrack:
    [avplayer pause];
    avplayer = [[AVPlayer alloc] initWithPlayerItem:/*name of item*/];
    [avplayer play];
    break;
于 2012-07-19T18:37:44.377 回答