ios - 在锁定屏幕上设置和访问 iOS 搜索栏

标签 ios avfoundation avaudioplayer seekbar

我正在使用 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 更改事件。

Here is the screen capture of lock screen.

最佳答案

我相信支持向前和向后搜索的唯一方法是使用上一个/前进按钮(它们在按住时发送开始/结束搜索通知)。

UIEventSubtypeRemoteControlBeginSeekingBackward, UIEventSubtypeRemoteControlBeginSeekingForward, 
UIEventSubtypeRemoteControlEndSeekingBackward, UIEventSubtypeRemoteControlEndSeekingForward

根据其他一些问题和文档,只能通过 Apple 自己的应用程序(https://stackoverflow.com/a/20142141/535632https://stackoverflow.com/a/20909875/535632)访问搜索栏。根据最后一个答案,似乎某些应用程序(尤其是 Spotify)通过音乐播放器路由他们的音乐以利用搜索栏。

关于ios - 在锁定屏幕上设置和访问 iOS 搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21549846/

相关文章:

ios - UITableViewCell布局问题

ios - Objective-C 如何使用 AVFoundation 向视频添加叠加层?

ios - 在后台 IOS 中实现长时间运行的任务

iphone - 苹果商业提供的波形API?

swift - 如何在应用程序关闭的情况下运行后台计时器并在 Swift 中播放音频样本

ios - SCN Material : can't find init:mdlMaterial:

html - IOS不正确的边框宽度渲染

ios - ResearchKit 步行任务不返回心率数据

iphone - 是否要在后台队列中调用 AVAudioPlayer 的 -prepareToPlay?

ios - 重新编辑: Audio not playing in real ios Device but playing in simulated devices in Swift2