iOS Media Playback Controls Notification

iOS media playback controls notification

From a comment:

i don't have a real device, i am using the IPhone 11 pro max simulator

That’s the problem. You cannot test this feature except on a device. The simulator is not a reliable guide for many iOS features / behaviors, and this is one of them. Without a device, you have no evidence of whether your code works as desired.

Custom audio player controls on notification ios

It is simple, and no third party library required for it

import MediaPleyer

And add observer on remote control Like

MPRemoteCommandCenter.shared().pauseCommand.addTarget(self, action: #selector(self.onPauseRemoteCommand(_:)))
MPRemoteCommandCenter.shared().playCommand.addTarget(self, action: #selector(self.onPlayRemoteCommand(_:)))

Audio playback lock screen controls not displaying on iPhone

The issue turned out to be this line...

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: AVAudioSessionCategoryOptions.duckOthers)

Once I changed it to

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: [])

everything worked fine. So it seems that passing in any argument for AVAudioSessionCategoryPlaybackOptions causes the lock screen controls to not display. I also tried passing in .mixWithOthers an that too caused the lock screen controls to not be displayed

Is there any way to hide the video controls from Notification Center on iOS 11.0?

WebView core functions are handled by the OS, so i think its not possible but you should implement the video/audio handling natively using these classes:

  • MPNowPlayingInfoCenter (currenlty playing items)

  • MPRemoteCommandCenter (observe different events, play/pause/next.. )



Related Topics



Leave a reply



Submit