我正在使用 AVQueuePlayer/AVFoundation 在 iOS 应用程序中播放音频文件。 我已经设置了 MPNowPlayingInfoCenter 的正在播放信息,如专辑名称、艺术家、艺术作品、 像这样
NSMutableDictionary *albumInfo = [[NSMutableDictionary alloc] init];<br/>
MPMediaItemArtwork *artworkP;<br/>
UIImage *artWork = [UIImage imageNamed:album.imageUrl];<br/>
[albumInfo setObject:album.title forKey:MPMediaItemPropertyTitle];<br/>
[albumInfo setObject:album.auther forKey:MPMediaItemPropertyArtist];<br/>
[albumInfo setObject:album.title forKey:MPMediaItemPropertyAlbumTitle];<br/>
[albumInfo setObject:artworkP forKey:MPMediaItemPropertyArtwork];<br/>
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:albumInfo]
并且还在应用程序委托(delegate)中访问远程事件以从锁定屏幕播放、暂停、下一个、上一个事件。 但是搜索栏无法访问,即使我没有找到任何设置搜索属性的选项。
我想设置搜索属性并想在我的应用中访问搜索 slider 更改事件。
最佳答案
我相信支持向前和向后搜索的唯一方法是使用上一个/前进按钮(它们在按住时发送开始/结束搜索通知)。
UIEventSubtypeRemoteControlBeginSeekingBackward, UIEventSubtypeRemoteControlBeginSeekingForward,
UIEventSubtypeRemoteControlEndSeekingBackward, UIEventSubtypeRemoteControlEndSeekingForward
根据其他一些问题和文档,只能通过 Apple 自己的应用程序(https://stackoverflow.com/a/20142141/535632、https://stackoverflow.com/a/20909875/535632)访问搜索栏。根据最后一个答案,似乎某些应用程序(尤其是 Spotify)通过音乐播放器路由他们的音乐以利用搜索栏。
关于ios - 在锁定屏幕上设置和访问 iOS 搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21549846/