Post

Replies

Boosts

Views

Activity

Dismissing AVPlayerViewController doesn't 'kill' the object - it's persisting on lock screen / media controls
I am playing videos that are in my app bundle.They are playing correctly.However, when I call to dismiss the AVPlayerViewController, it visibly is removed from the view hierarchy but, if I turn off the iOS device and turn it back on again, on the lock screen there is a media control showing that video and a 'play' button.If you touch play you only get the audio and no video.My problem is I don't understand why the 'dismiss' is not completely 'killing' the player when I'm done with it.NOTE: The follow code works perfectly in iOS 13 devices, however any device running previous iOS versions, the error appears as stated. This is blocking me from submitting my app, please can someone advise on how to solve this? Here is the presentation code: internal func play(FileName filename: String, FileType type: String) { if self.isAlreadyPlaying == YES { killVideoPlayer() DispatchQueue.main.asyncAfter(deadline: .now() + 1.5, execute: { self.play(FileName: filename, FileType: type) }) return } let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(AVAudioSession.Category.playback, mode: .moviePlayback, options: [.allowAirPlay, .allowBluetooth, .allowBluetoothA2DP]) try audioSession.setActive(true) } catch { print("Audio session failed") } let path = Bundle.main.path(forResource: filename, ofType: type) let url = NSURL(fileURLWithPath: path!) let player = AVPlayer(url: url as URL) NotificationCenter.default.addObserver(self, selector: #selector(PBFMenuSystemFloatingButtonsViewController.didFinishPlaying(notification:)), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem) self.playerController = AVPlayerViewController() self.menuWindow.videoPlayer = self.playerController self.playerController?.player = player self.playerController?.allowsPictureInPicturePlayback = true self.playerController?.showsPlaybackControls = YES self.playerController?.delegate = self self.playerController?.exitsFullScreenWhenPlaybackEnds = YES self.isAlreadyPlaying = YES self.present(self.playerController!, animated: true, completion : { self.playerController?.player?.play() }) } Here is the dismissal code: private func killVideoPlayer() { self.isAlreadyPlaying = NO self.playerController?.player?.pause() self.playerController?.player = nil let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setActive(false, options: .notifyOthersOnDeactivation) try audioSession.setCategory(.soloAmbient) } catch { print("Audio session failed") } self.playerController?.dismiss(animated: YES, completion: { self.playerController = nil }) } And here's what's remaining in the systemwide media player that is shown on the lock screen / control centre:
1
0
3.5k
Oct ’21
Vision Pro Passthrough of computer monitor?
I have a killer app idea, but I need to know if it's possible to watch a TV or PC monitor whilst wearing Vision Pro without any latency. i.e. Imagine playing a console game or PC game but having custom app overlays in 3D spatial world that you can still look at and interact with whilst still watching/playing the game on the 'real' monitor/tv.
Replies
0
Boosts
0
Views
1.2k
Activity
Jun ’23
Dismissing AVPlayerViewController doesn't 'kill' the object - it's persisting on lock screen / media controls
I am playing videos that are in my app bundle.They are playing correctly.However, when I call to dismiss the AVPlayerViewController, it visibly is removed from the view hierarchy but, if I turn off the iOS device and turn it back on again, on the lock screen there is a media control showing that video and a 'play' button.If you touch play you only get the audio and no video.My problem is I don't understand why the 'dismiss' is not completely 'killing' the player when I'm done with it.NOTE: The follow code works perfectly in iOS 13 devices, however any device running previous iOS versions, the error appears as stated. This is blocking me from submitting my app, please can someone advise on how to solve this? Here is the presentation code: internal func play(FileName filename: String, FileType type: String) { if self.isAlreadyPlaying == YES { killVideoPlayer() DispatchQueue.main.asyncAfter(deadline: .now() + 1.5, execute: { self.play(FileName: filename, FileType: type) }) return } let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(AVAudioSession.Category.playback, mode: .moviePlayback, options: [.allowAirPlay, .allowBluetooth, .allowBluetoothA2DP]) try audioSession.setActive(true) } catch { print("Audio session failed") } let path = Bundle.main.path(forResource: filename, ofType: type) let url = NSURL(fileURLWithPath: path!) let player = AVPlayer(url: url as URL) NotificationCenter.default.addObserver(self, selector: #selector(PBFMenuSystemFloatingButtonsViewController.didFinishPlaying(notification:)), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem) self.playerController = AVPlayerViewController() self.menuWindow.videoPlayer = self.playerController self.playerController?.player = player self.playerController?.allowsPictureInPicturePlayback = true self.playerController?.showsPlaybackControls = YES self.playerController?.delegate = self self.playerController?.exitsFullScreenWhenPlaybackEnds = YES self.isAlreadyPlaying = YES self.present(self.playerController!, animated: true, completion : { self.playerController?.player?.play() }) } Here is the dismissal code: private func killVideoPlayer() { self.isAlreadyPlaying = NO self.playerController?.player?.pause() self.playerController?.player = nil let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setActive(false, options: .notifyOthersOnDeactivation) try audioSession.setCategory(.soloAmbient) } catch { print("Audio session failed") } self.playerController?.dismiss(animated: YES, completion: { self.playerController = nil }) } And here's what's remaining in the systemwide media player that is shown on the lock screen / control centre:
Replies
1
Boosts
0
Views
3.5k
Activity
Oct ’21