在我的应用程序中,播放是由控制中心控制的。当在AVPlayer中进行播放时(此时播放控件在控制中心工作正常),我正在加载带有其他流媒体URL的webview。再次完成流式传输后,我将开始从AVPlayer播放。在此之后,播放控件在控制中心中变灰。我正在使用[MPNowPlayingInfoCenterdefaultCenter].nowPlayingInfo在控制中心启用播放控制。会出现什么问题? 最佳答案 我在使用AVPlayer实例时也遇到了这个问题。您可以使用MPRemoteCommandCenter在锁定屏幕和命令中心上设置
这是我从命令中心观察变化的方式:commandCenter.playCommand.addTarget(self,action:#selector(play))commandCenter.pauseCommand.addTarget(self,action:#selector(pause))commandCenter.changePlaybackPositionCommand.addTarget{eventinletseconds=(eventas?MPChangePlaybackPositionCommandEvent)?.positionTime??0lettime=CMTime(
我正在使用AVPlayer在我的iOS应用程序中播放音频(因为我正在播放的音频文件不是本地的),当我的轨道结束时,我想隐藏信息中心控件,但我得到这个错误:AVAudioSession.mm:1079:-[AVAudioSessionsetActive:withOptions:error:]:停用正在运行I/O的AudioSession。在停用AudioSession之前,应停止或暂停所有I/O。不过,我之前暂停了我的AVPlayer。这是我的代码:player.pause()player.replaceCurrentItem(with:nil)MPNowPlayingInfoCente
我有一个使用AVPlayer在后台播放音频的应用程序。我使用MPNowPlayingInfoCenter在锁定屏幕和控制中心上显示歌曲的元数据。除了一件事,一切正常。锁定屏幕和控制中心上的Remote是播客应用程序的Remote。它们没有前进和上一个按钮。我有一个控件的屏幕截图:如您所见,我没有前进和上一个按钮。overridefuncviewDidLoad(){super.viewDidLoad()do{tryAVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)UIApplication
我想构建一个广播应用程序,所以我想在控制中心使用停止按钮而不是暂停按钮,就像AppleRadio在native音乐应用程序中所做的那样:这是我在RadioPlayer类中所做的:privatevarshoutcastStream=NSURL(string:"http://shoutcast.com:PORT/;stream.mp3")varplayerItem:AVPlayerItem?varplayer:AVPlayer?letcommandCenter=MPRemoteCommandCenter.sharedCommandCenter()overrideinit(){super.i
MPRemoteCommandCenter多次调用处理程序block并导致对选择器方法的不必要调用。这是代码片段:MPRemoteCommandCenter*commandCenter=[MPRemoteCommandCentersharedCommandCenter];[commandCenter.nextTrackCommandaddTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent*_Nonnullevent){NSLog(@"NEXTTTTTT");returnMPRemoteCommandH
MPRemoteCommandCenter多次调用处理程序block并导致对选择器方法的不必要调用。这是代码片段:MPRemoteCommandCenter*commandCenter=[MPRemoteCommandCentersharedCommandCenter];[commandCenter.nextTrackCommandaddTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent*_Nonnullevent){NSLog(@"NEXTTTTTT");returnMPRemoteCommandH