     }
 }
 
-extension MPMusicPlayerController {
-    class var cleanApplicationMusicPlayer: MPMusicPlayerController {
-        let result = applicationMusicPlayer
-        result.setQueue(with: [])
-        result.currentPlaybackTime = 0.0
-        return result
-    }
-}
-
 // MARK: - SystemVolumeMonitor
 
 public extension NSNotification.Name {

            NotificationCenter.default.post(name: .SystemVolumeMonitor, userInfo: ["volume":0.0])
        }
        
        player.beginGeneratingPlaybackNotifications()
    }

    deinit {
        player.setQueue(with: MPMediaItemCollection(items: []))
        NotificationCenter.default.removeObserver(self)
        player.endGeneratingPlaybackNotifications()
    }
    
    @discardableResult public func play() -> Bool {
        //setting playback rate has side effect of starting playback
        player.currentPlaybackRate = playbackRate
        playbackBegun = true
        return isPlaying()
    }
    
    public func isPlaying() -> Bool {
        player.playbackState == .playing
    }
    
    @discardableResult public func pause() -> Bool {
        player.pause()
        return isPaused()
    }
    
    public func isPaused() -> Bool {
        player.playbackState == .paused
    }
        
    public func stop() {
        player.stop()
    }
    
    private func setupPlayer() {
        player.repeatMode = .none
        player.shuffleMode = .off

        if let id = mediaItem?.playbackStoreID {
            player.setQueue(with: [id])
            player.prepareToPlay() { error in
                guard let error = error else {
                    return
                }
                
                print("Error in MPMusicPlayerController.prepareToPlay: \(error)")
            }
        }
    }
}


///This is a thin wrapper on MPMusicPlayerController to give us interface consistency with AudioPlayer for factory construction
public class MusicPlayer: AudioPlayer {
    private static var player: MPMusicPlayerController = {
        let player = MPMusicPlayerController.applicationMusicPlayer
        player.repeatMode = .none
        player.shuffleMode = .off
        player.beginGeneratingPlaybackNotifications()
        
        NotificationCenter.default.addObserver(forName: .MPMusicPlayerControllerVolumeDidChange,
                                               object: player,
