Ambiguous use of play of MPMusicPlayerController in iOS11, swift4

陌路散爱 提交于 2019-12-23 03:51:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!