我尝试控制用户可以在歌曲播放中提前几秒 . 我管理的只是用户可以看到播放头但不与它交互 .
我在AVAudioSessionCategoryPlayback模式下使用AVAudioSession . AVPlayer和AVPlayerItem
_playerItem = [AVPlayerItem playerItemWithURL:url];
_player = [AVPlayer playerWithPlayerItem:self.playerItem];
[ EDIT ]这样,我控制远程事件:
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
//if it is a remote control event handle it correctly
if (event.type == UIEventTypeRemoteControl)
{
if (event.subtype == UIEventSubtypeRemoteControlPlay) {
NSLog(@"Responds nice to the event UIEventSubtypeRemoteControlPlay");
} else if (event.subtype == UIEventSubtypeRemoteControlPause) {
NSLog(@"Responds nice to the event UIEventSubtypeRemoteControlPause");
} else if (event.subtype == UIEventSubtypeRemoteControlTogglePlayPause) {
NSLog(@"Responds nice to the event UIEventSubtypeRemoteControlTogglePlayPause");
} else if (event.subtype == UIEventSubtypeRemoteControlBeginSeekingBackward) {
NSLog(@"NEVER Responds!!!");
} else if (event.subtype == UIEventSubtypeRemoteControlBeginSeekingForward) {
NSLog(@"NEVER Responds!!!");
} else if (event.subtype == UIEventSubtypeRemoteControlNextTrack){
NSLog(@"Responds nice to the event UIEventSubtypeRemoteControlNextTrack");
} else if (event.subtype == UIEventSubtypeRemoteControlPreviousTrack){
NSLog(@"Responds nice to the event UIEventSubtypeRemoteControlPreviousTrack");
} else if (event.subtype == UIEventSubtypeRemoteControlStop){
NSLog(@"Responds nice to the event UIEventSubtypeRemoteControlStop");
}
}
}
如何激活在backgroud音频中运行的遥控器(见屏幕截图)中的栏(iPhone被阻止) . 甚至不知道是否可能 .
¿有可能吗?在'音乐原生App iOS'工作正常!
1 回答
AVPlayer
类有一个seekToTime:
方法,可以执行您想要的操作 .在进度条回调中,将进度条位置表示的百分比乘以总介质时间,并将该值传递给
seekToTime:
.