问题
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.
回答1:
Write
(musicPlayerController as MPMediaPlayback).play()
来源:https://stackoverflow.com/questions/45099065/ambiguous-use-of-play-of-mpmusicplayercontroller-in-ios11-swift4