使用 Apple 提供的 MusicKit 示例应用程序时遇到问题
Having trouble with MusicKit sample app provided by Apple
我正在尝试在 Xcode 9 beta 3 上构建“将内容添加到 Apple Music”,Apple 提供的 Music Kit 示例应用程序。但是我有 4 个这样的错误:三个“模棱两可的使用'play()'”错误和一个“'pause()'使用不明确”
如果您已经解决了这个问题,请告诉我如何解决这个问题。
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 的开发论坛上发现了一个类似的问题:
MPMusicPlayerController Swift4 - Ambiguous Use of Play
根据条目编写解决此问题的修复程序,您需要更改 MusicPlayerManager.swift 中的这一行:
let musicPlayerController = MPMusicPlayerController.systemMusicPlayer
(musicPlayerController
的类型变成 MPMusicPlayerController & MPSystemMusicPlayerController
与此代码。)
收件人:
let musicPlayerController: MPMusicPlayerController = MPMusicPlayerController.systemMusicPlayer
(musicPlayerController
被显式注释为 MPMusicPlayerController
。)
在我看来,这是 Swift 与 SE-0156 Class and Subtype existentials and you should better send a bug report to Apple or swift.org 有关的错误。
我正在尝试在 Xcode 9 beta 3 上构建“将内容添加到 Apple Music”,Apple 提供的 Music Kit 示例应用程序。但是我有 4 个这样的错误:三个“模棱两可的使用'play()'”错误和一个“'pause()'使用不明确”
如果您已经解决了这个问题,请告诉我如何解决这个问题。
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 的开发论坛上发现了一个类似的问题:
MPMusicPlayerController Swift4 - Ambiguous Use of Play
根据条目编写解决此问题的修复程序,您需要更改 MusicPlayerManager.swift 中的这一行:
let musicPlayerController = MPMusicPlayerController.systemMusicPlayer
(musicPlayerController
的类型变成 MPMusicPlayerController & MPSystemMusicPlayerController
与此代码。)
收件人:
let musicPlayerController: MPMusicPlayerController = MPMusicPlayerController.systemMusicPlayer
(musicPlayerController
被显式注释为 MPMusicPlayerController
。)
在我看来,这是 Swift 与 SE-0156 Class and Subtype existentials and you should better send a bug report to Apple or swift.org 有关的错误。