How to implement seeking from ControlCenter?

1.1k views Asked by At

I'm trying to implement support for the playback controls available in Control Center. For play/pause etc I'm handling UIEventTypeRemoteControl events and looking for subtype UIEventSubtypeRemoteControlPlay / UIEventSubtypeRemoteControlPause, etc.

However when I try and drag the playback position I don't get any events. Is there a different method for handling seeking?

2

There are 2 answers

0
Anuj Rajput On BEST ANSWER

You can't seek track position using the track seek bar like it does when using Music app. For seek bar to work with your app, the track should be in the device's music library. I noticed quite a few apps which support lock screen/control center track seeking, they get their tracks from the Music Library in the device. Apps like SoundCloud don't support seeking track to position at this point of time

The only way to support forward and backward seeking is by the previous/next buttons which send a begin/end seeking notification when long pressed.

UIEventSubtypeRemoteControlBeginSeekingBackward, UIEventSubtypeRemoteControlBeginSeekingForward, 
UIEventSubtypeRemoteControlEndSeekingBackward, UIEventSubtypeRemoteControlEndSeekingForward

According to the other answers it seems that seeking is not possible right now. https://stackoverflow.com/a/21555847/1781918, https://stackoverflow.com/a/20909875/1781918

0
user1502383 On

List of events:

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

Also MPNowPlayingInfoCenter have this key:

MPNowPlayingInfoPropertyElapsedPlaybackTime;