How to implement seeking from ControlCenter?
Asked Answered
S

2

8

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?

Scrivner answered 14/11, 2014 at 22:49 Comment(0)
M
9

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://mcmap.net/q/1468214/-setting-and-accessing-ios-seek-bar-on-lock-screen, https://mcmap.net/q/672752/-how-to-enable-audio-scrubber-in-ios-lock-screen-control-panel

Mohn answered 24/11, 2014 at 7:2 Comment(0)
O
0

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; 
Onto answered 18/11, 2014 at 17:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.