Ios MPNowPlayingFoCenter不使用WKWebView播放
我正在使用Ios MPNowPlayingFoCenter不使用WKWebView播放,ios,wkwebview,mpnowplayinginfocenter,Ios,Wkwebview,Mpnowplayinginfocenter,我正在使用WKWebView播放音频/视频,并希望设置自定义mpnowplayingfocenternowPlayingInfo,但WKWebView似乎覆盖了我所做的任何设置。是否有人能够在使用WKWebView时添加自定义锁屏控件和元数据 下面是我正在使用的代码的浓缩示例: [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategory
WKWebView
播放音频/视频,并希望设置自定义mpnowplayingfocenter
nowPlayingInfo
,但WKWebView
似乎覆盖了我所做的任何设置。是否有人能够在使用WKWebView
时添加自定义锁屏控件和元数据
下面是我正在使用的代码的浓缩示例:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
// ... create the WKWebView and play the video ...
NSMutableDictionary * const mutableNowPlayingInfo = [NSMutableDictionary dictionary];
mutableNowPlayingInfo[MPMediaItemPropertyArtist] = [playlistItem videoCreator] ?: @"";
mutableNowPlayingInfo[MPMediaItemPropertyTitle] = [playlistItem videoName] ?: @"";
mutableNowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = [playlistItem videoDuration] ?: @(0.0);
mutableNowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = @(1.0);
MPNowPlayingInfoCenter * const infoCenter = [MPNowPlayingInfoCenter defaultCenter];
[infoCenter setNowPlayingInfo:mutableNowPlayingInfo];
请注意,-remoteControlReceivedWithEvent:
在我的AppDelegate
类中也会根据需要被重写
另外请注意,如果将
WKWebView
替换为AVPlayer
或AVAudioPlayer
,则此操作正常。我也有类似问题:-(值得一提的是,我用DTS票证联系了苹果公司,他们回答说这是故意的。现在看起来没有解决方案。@AaronWojnowski:有解决方案吗?没有:(@Nishan29Hey!你找到解决方案了吗?1.5年过去了。。。