本文介绍了如何在remoteControlledEvents中选择下一首歌曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用AVPlayer
,在这里我可以通过双击主屏幕按钮或按技术术语remoteControlledEvents
来控制播放,暂停功能.我想知道如何实现它,以便可以转到remoteControlledEvents
中的下一个轨道.
I am using AVPlayer
where I can control play, pause function by double tapping home button or in technical terms remoteControlledEvents
. I was wondering how to implement it so I can go to the next track in 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;
}
}
推荐答案
用下一首歌制作新的AVPlayer
并告诉其播放.
Make a new AVPlayer
with the next song and tell it to play.
事件为UIEventSubtypeRemoteControlNextTrack
case: UIEventSubtypeRemoteControlNextTrack:
[avplayer pause];
avplayer = [[AVPlayer alloc] initWithPlayerItem:/*name of item*/];
[avplayer play];
break;
这篇关于如何在remoteControlledEvents中选择下一首歌曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!