9

I am trying to setup my app to use MPRemoteCommandCenter. I got this example from the document programming guide. I imported AVFoundation and even tried importing AVKIT, I am getting the error Use of unresolved identifier 'MPRemoteCommandCenter'. When I create an instance of MPRemoteCommandCenter.shared(). Any help would be appreciated.

func setupRemoteTransportControls() {

    // Get the shared MPRemoteCommandCenter
    let commandCenter = MPRemoteCommandCenter.shared()   Error //**Use of unresolved identifier 'MPRemoteCommandCenter'**

    // Add handler for Play Command
    commandCenter.playCommand.addTarget { [unowned self] event in
        if self.audioPlayer.rate == 0.0 {
            self.audioPlayer.play()
            return .success
        }
        return .commandFailed
    }

    // Add handler for Pause Command
    commandCenter.pauseCommand.addTarget { [unowned self] event in
        if self.audioPlayer.rate == 1.0 {
            self.audioPlayer.pause()
            return .success
        }
        return .commandFailed
    }
}
nayem
  • 7,285
  • 1
  • 33
  • 51
Iam Wayne
  • 561
  • 6
  • 26

1 Answers1

32

You need to import MediaPlayer

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159