0

I would like to change play/pause button icon on a lock screen when I tap play/pause in the app.

When I tap play/pause from a lock screen, I receive it in the app and update the view, but when I tap it in the app, it doesn't update on a lock screen.

I was trying to do it this way:

NSMutableDictionary *currentlyPlayingTrackInfoDict = [[NSMutableDictionary alloc] initWithCapacity:3];

[currentlyPlayingTrackInfoDict setObject:[NSNumber numberWithFloat:[[AudioPlaybackManager shared] isPlaying] ? 1.0f : 0.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate];
[currentlyPlayingTrackInfoDict setObject:[NSNumber numberWithFloat:10.0] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
[currentlyPlayingTrackInfoDict setObject:[NSNumber numberWithFloat:100.0] forKey:MPMediaItemPropertyPlaybackDuration];

[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:currentlyPlayingTrackInfoDict];

but it only affects seek bar.

Has anyone encountered a similar problem? Should I set something else?

Mateusz
  • 233
  • 3
  • 8
  • take a look: https://stackoverflow.com/questions/53986069/swift-remote-command-center-not-show-in-lockscreen/53986756#53986756 – raphael Jan 27 '19 at 11:29
  • I've downloaded the example project from github and they hide the whole lock screen control view when you pause/stop player. I would like to keep it always visible and only update play/pause controls. – Mateusz Jan 27 '19 at 17:59
  • Lock screen control belong to Apple, but we can think play / pause or play / stop depend on rate's avplayeritem. `MPNowPlayingInfoPropertyPlaybackRate ` shouldn't be set at 0: positive or negative value. From ModernAVPlayer project, didn't have any issue about that. – raphael Jan 28 '19 at 08:14

0 Answers0