如何在控制中心实现快进操作?

8
我正在尝试实现对控制中心中的播放控件的支持。对于播放/暂停等操作,我将处理 UIEventTypeRemoteControl 事件,并查找 UIEventSubtypeRemoteControlPlay / UIEventSubtypeRemoteControlPause 等子类型事件。

然而,当我尝试拖动播放进度时,我没有收到任何事件。是否有不同的方法来处理寻找(seeking)?

2个回答

9
你不能像使用音乐应用程序一样使用跟踪搜索栏来寻找跟踪位置。对于搜索栏与应用程序的配合使用,需要在设备的音乐库中拥有跟踪。我发现有很多应用程序支持锁屏/控制中心跟踪搜索,它们从设备的音乐库中获取其跟踪。像SoundCloud这样的应用程序目前不支持搜索跟踪到特定位置。
唯一支持向前和向后搜索的方法是通过上一个/下一个按钮,在长按时发送开始/结束搜索通知。
UIEventSubtypeRemoteControlBeginSeekingBackward, UIEventSubtypeRemoteControlBeginSeekingForward, 
UIEventSubtypeRemoteControlEndSeekingBackward, UIEventSubtypeRemoteControlEndSeekingForward

根据其他答案,目前似乎无法进行搜索。 https://dev59.com/bnzaa4cB1Zd3GeqPLRfK#21555847, https://dev59.com/oGMk5IYBdhLWcg3w0RGU#20909875

0

事件列表:

   UIEventSubtypeRemoteControlPlay
   UIEventSubtypeRemoteControlPause
   UIEventSubtypeRemoteControlStop
   UIEventSubtypeRemoteControlTogglePlayPause
   UIEventSubtypeRemoteControlNextTrack
   UIEventSubtypeRemoteControlPreviousTrack
   // may be it is what you want
   UIEventSubtypeRemoteControlBeginSeekingBackward
   UIEventSubtypeRemoteControlEndSeekingBackward
   UIEventSubtypeRemoteControlBeginSeekingForward
   UIEventSubtypeRemoteControlEndSeekingForward 

此外,MPNowPlayingInfoCenter也有这个键:

MPNowPlayingInfoPropertyElapsedPlaybackTime; 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接