How can I make the Control Center slider editable?

后端 未结 6 883
栀梦
栀梦 2021-01-04 20:54

I\'m working on an app that will play sound files. If I open apple music app, the slider let me moving between the song where I am.

Other apps like spotify

6条回答
  •  孤街浪徒
    2021-01-04 21:11

    There is the changePlaybackPositionCommand API with the associated Event MPChangePlaybackPositionCommandEvent.positionTime (see https://developer.apple.com/library/ios/releasenotes/General/iOS91APIDiffs/Objective-C/MediaPlayer.html)

    I tried

    [commandCenter.changePlaybackPositionCommand
                         addTarget: self
                            action: @selector( onChangePlaybackPositionCommand: )]
    

    with the associated method

    - (MPRemoteCommandHandlerStatus) onChangePlaybackPositionCommand:
                                         (MPChangePlaybackPositionCommandEvent *) event
    {
        NSLog(@"changePlaybackPosition to %f", event.positionTime);
        return MPRemoteCommandHandlerStatusSuccess;
    }
    

    but the cursor is still not movable and the method is not called. I guess I still miss something

提交回复
热议问题