1

I'm running the Apple iOS11 example Adding Content to Apple Music on Xcode Version 9.0 beta 3 (9M174d).

I get a Ambiguous use of 'play() in

/adding-content-to-apple-music/AppleMusicSample/Controllers/MusicPlayerManager.swift:78:9: Ambiguous use of 'play()'

The suggested solutions to explicitly define the selector in order to avoid the ambiguity like:

let play = #selector(musicPlayerController.play)

did not work in this case.

The MPMusicPlayerController instance in the MusicPlayerManager class is defined as

let musicPlayerController = MPMusicPlayerController.systemMusicPlayer 

and then referred like

func beginPlayback(itemID: String) {
        musicPlayerController.setQueue(with: [itemID])

        musicPlayerController.play()
    }

I have put the code for the MusicPlayerManager class here.

loretoparisi
  • 15,724
  • 11
  • 102
  • 146
  • 1
    Please check [this thread](https://stackoverflow.com/q/45080188/6541007). – OOPer Jul 14 '17 at 09:13
  • @OOPer thank you! That's crazy. It is just that cast/annotation, sort of :D – loretoparisi Jul 14 '17 at 09:18
  • Please thank who first posted the workaround on the web. Sharing the developers' experience is really a great thing. – OOPer Jul 14 '17 at 09:28
  • @OOPer can you reply as answer so I will accept? Thank you! – loretoparisi Jul 14 '17 at 11:06
  • @OOPer btw here another: https://stackoverflow.com/questions/45101444/swiftdeferrednsdictionary-objectforkeynotnull-in-ios11-and-swift4 – loretoparisi Jul 14 '17 at 11:07
  • 1
    Maybe this question should be marked as duplicate with the link above. I'll take some time to check your another. – OOPer Jul 14 '17 at 11:49
  • 2
    Possible duplicate of [Having trouble with MusicKit sample app provided by Apple](https://stackoverflow.com/questions/45080188/having-trouble-with-musickit-sample-app-provided-by-apple) – loretoparisi Jul 14 '17 at 12:38
  • Voted to close as a duplicate, but your description of the problem is excellent (you provide just the info needed to reproduce the problem minimally) so also upvoted. :) – matt Jul 14 '17 at 22:21
  • 1
    I should also mention, it wouldn't hurt to file a bug with Apple on this. The more the merrier, as you probably know. – matt Jul 16 '17 at 20:05

1 Answers1

3

Write

    (musicPlayerController as MPMediaPlayback).play()
matt
  • 515,959
  • 87
  • 875
  • 1,141