Skip to content

Commit

Permalink
Merge pull request #76 from dasantonym/main
Browse files Browse the repository at this point in the history
Use MediaPlayer's MPNowPlayingInfoCenter to remove nowPlayingInfo
  • Loading branch information
phiamo committed Aug 20, 2023
2 parents 3964602 + 06d6693 commit 17b49e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ios/Plugin/AVBidirectionalQueuePlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
//

import AVFoundation
import MediaPlayer

let AVBidirectionalQueueAddedItem = "AVBidirectionalQueuePlayer.AddedItem"
let AVBidirectionalQueueAddedAllItems = "AVBidirectionalQueuePlayer.AddedAllItems"
Expand Down Expand Up @@ -199,6 +200,8 @@ class AVBidirectionalQueuePlayer: AVQueuePlayer {
super.removeAllItems()
queuedAudioTracks.removeAll()

MPNowPlayingInfoCenter.default().nowPlayingInfo?.removeAll()

NotificationCenter.default.post(name: NSNotification.Name(AVBidirectionalQueueCleared), object: self, userInfo: nil)
}

Expand All @@ -207,7 +210,7 @@ class AVBidirectionalQueuePlayer: AVQueuePlayer {
removeTrackObservers(item)
}
}

func removeTrackObservers(_ playerItem: AudioTrack?) {
NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: playerItem)
NotificationCenter.default.removeObserver(self, name: .AVPlayerItemPlaybackStalled, object: playerItem)
Expand Down

0 comments on commit 17b49e8

Please sign in to comment.