我正在使用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;
}
}
答案 0 :(得分:1)
使用下一首歌创建一个新AVPlayer
并告诉它播放。
活动为UIEventSubtypeRemoteControlNextTrack
case: UIEventSubtypeRemoteControlNextTrack:
[avplayer pause];
avplayer = [[AVPlayer alloc] initWithPlayerItem:/*name of item*/];
[avplayer play];
break;