当 Airpods 已连接且没有正在播放的音乐时,Siri 会在 Apple 音乐应用和 Resso 的“正在播放”小部件上方建议播放列表/歌曲。
这可能是由于 Siri 的“Show When listening”建议,当我关闭它时它就不再出现了。
我也在我的项目中尝试过捐赠歌曲和推荐歌曲。但它仍然不适合我。我使用的代码如下:
var inImage: INImage?
if let cResource = ImageTask.sharedTask.cachedResource(item: song, requiredType: ImageType.small, thumborUrlForRequiredType: nil, lookOnDisk: true) {
let imageData = cResource.image!.jpegData(compressionQuality: 0.9)
inImage = INImage(imageData: imageData!)
}
let item = INMediaItem(identifier: song.id, title: song.title, type: .song, artwork: inImage, artist: song.artistTitle)
let intentItem = INPlayMediaIntent(mediaContainer: item)
let set = NSOrderedSet(array: [intentItem])
INUpcomingMediaManager.shared.setSuggestedMediaIntents(set)
let interaction = INInteraction(intent: intentItem, response: nil)
interaction.groupIdentifier = "in.myapp"
interaction.donate { (error) in
if error != nil {
Log.logDebug(message: "&*&*&*&*&*&*&*&*&*&*&*&*: failure, \(String(describing: intent.mediaContainer?.title))")
}else {
Log.logDebug(message: "&*&*&*&*&*&*&*&*&*&*&*&*: success, \(String(describing: intent.mediaContainer?.title))")
}
}