mpremotecommandcenter

command center Scrubber on lock screen swift

最后都变了- 提交于 2021-01-28 08:01:09
问题 I am trying to add scrubber to command center lock screen, I am getting this error Cannot assign to value: function call returns immutable value I don't know what it means. Any help would be appreciated. This is how I am trying to change the position commandCenter.changePlaybackPositionCommand.addTarget(handler: { (event) in let event = event as! MPChangePlaybackPositionCommandEvent self.player.currentTime() = event.positionTime // ERROR return MPRemoteCommandHandlerStatus.success }) 回答1: I

iOS media playback controls notification

我与影子孤独终老i 提交于 2020-02-22 07:25:13
问题 I am new to iOS, and developing a cross platform app with Flutter. I am trying to play audio from network URL, which i found it can be done using the AVPlayer . The audio plays when the app is in foreground and in background, but i can display the media playback controls like this: . i used the let mediaController = MPMusicPlayerController.applicationMusicPlayer and then calling self.mediaController.beginGeneratingPlaybackNotifications() , also providing the playing info

MPRemoteCommandCenter pause/play button create more sharedInstance of AVAudioPlayer?

こ雲淡風輕ζ 提交于 2020-01-25 06:50:29
问题 My app is a music player using AVAudioPlayer with Singleton pattern and background mode. Things are going well, but after I add command center for locked screen control, one strange behavior I found. When I use the pause/play button in locked screen, sometimes it may create additional sharedInstance of audioPlay on background , because I found more than ones times duplicate printing, e.g. in my commandCenter.pauseCommand code. And audio is paused or resume playing but next click on both

Swift: Remote Command Center not show in lockScreen

孤街浪徒 提交于 2020-01-16 18:24:12
问题 Iam trying to show command center in lock screen and not woking for me, i see the code from this tutorial, and write the same code but also not working https://github.com/lukagabric/LGAudioPlayerLockScreen this is the code var nowPlayingInfo = [MPMediaItemPropertyTitle: currentPlaybackItem.trackName, MPMediaItemPropertyAlbumTitle: currentPlaybackItem.albumName, MPMediaItemPropertyArtist: currentPlaybackItem.artistName, MPMediaItemPropertyPlaybackDuration: audioPlayer.duration,

Music info showing in Command Center but not Lock Screen

落花浮王杯 提交于 2019-12-22 09:31:31
问题 Using Swift 4+, iOS 11+, Xcode 10+ I've built a music player using MPMediaPlayer and I can interact with it from the Command Center, however I would like to be able to also see it on the Lock Screen. To be honest, I'm a bit confused as to why it's showing/working in the Command Center as I have not written any code to do this. Nevertheless, I would also like it to show in the Lock Screen. This is what I have done so far: 1) I'm using the applicationMusicPlayer and made certain something is