遇到Apple提供的MusicKit示例应用程序的麻烦 [英] Having trouble with MusicKit sample app provided by Apple
问题描述
我正在尝试在Xcode 9 beta 3上构建由Apple提供的Music Kit示例应用程序向Apple Music添加内容".但是,我遇到了4个类似的错误:3"play()"的歧义使用)错误和一个歧义使用'pause()'"
I am trying to build "Adding Content to Apple Music", Music Kit sample app provided by Apple, on Xcode 9 beta 3. However I am having 4 errors like this : three "Ambiguous use of 'play()’" errors and one "Ambiguous use of 'pause()’"
如果您已解决此问题,请告诉我如何解决.
Please tell me how to fix this if you already solved this problem.
func beginPlayback(itemCollection: MPMediaItemCollection) {
musicPlayerController.setQueue(with: itemCollection)
//Ambiguous use of 'play()’
musicPlayerController.play()
}
func beginPlayback(itemID: String) {
musicPlayerController.setQueue(with: [itemID])
//Ambiguous use of 'play()’
musicPlayerController.play()
}
// MARK: Playback Control Methods
func togglePlayPause() {
if musicPlayerController.playbackState == .playing {
//Ambiguous use of 'pause()’
musicPlayerController.pause()
} else {
//Ambiguous use of 'play()’
musicPlayerController.play()
}
}
推荐答案
我在Apple开发论坛中发现了类似的问题:
I have found a similar question in the Apple's Dev Forums:
MPMusicPlayerController Swift4-玩游戏的模棱两可
根据写解决此问题的修补程序的条目,您需要在MusicPlayerManager.swift中更改此行:
According to an entry writing a fix to work around the issue, you need to change this line in MusicPlayerManager.swift:
let musicPlayerController = MPMusicPlayerController.systemMusicPlayer
(使用此代码,musicPlayerController
的类型变为MPMusicPlayerController & MPSystemMusicPlayerController
.)
(musicPlayerController
's type becomes MPMusicPlayerController & MPSystemMusicPlayerController
with this code.)
收件人:
let musicPlayerController: MPMusicPlayerController = MPMusicPlayerController.systemMusicPlayer
(musicPlayerController
显式标注为MPMusicPlayerController
.)
我认为这是Swift的错误,与 Apple 或 swift.org .
In my opinion this is a bug of Swift related to SE-0156 Class and Subtype existentials and you should better send a bug report to Apple or swift.org.
这篇关于遇到Apple提供的MusicKit示例应用程序的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!