MPMusicPlayerController Swift4 - Ambiguous Use of Play

I'm trying on iOS11 / Xcode9 - beta3 the sample app "Adding-Content-To-Apple-Music".


The code



musicPlayerController.play()




will give the error Ambiguous Use of play()

As suggested somewhere, this was some changes in swift3, so I have explicitly defined the selector like



let play = #selector(musicPlayerController.play)
lay()


but it didn't work.

Accepted Reply

Declaring the player providing the type is fixing the issue.


    let musicPlayerController:MPMusicPlayerController = MPMusicPlayerController.systemMusicPlayer

Replies

I have the exact same issue. Using Xcode 9b3, tried a few things but no luck.

I have the same issue and haven't found a solution yet. I was using MPMusicPlayerController.systemMusicPlayer to create the object which I call .play() on. When I switch to using MPMusicPlayerController.applicationMusicPlayer the errors go away for play() and stop(), but the actual playing functionality doesn't work. This is an app I had working under beta 2.

Declaring the player providing the type is fixing the issue.


    let musicPlayerController:MPMusicPlayerController = MPMusicPlayerController.systemMusicPlayer