如何显示流式Apple Music的专辑插图? [英] How to display album artwork of streamed Apple Music?

查看:410
本文介绍了如何显示流式Apple Music的专辑插图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用iOS 9中新的Apple Music API(2016年5月12日发布)的音乐播放器中(快速,尽管我现在也很熟悉Objective-C),我可以显示流式歌曲中的信息,但不是艺术品.我正在使用MediaPlayer,UIKit和StoreKit框架.我已成功请求对AddToCloudMusicLibrary和MusicCatalogPlayback的授权.我已经成功地展示了从Apple Music应用程序下载的歌曲中的Apple Music艺术作品,以及我的个人歌曲集中的艺术作品.我见过其他对此有疑问的人,没有运气...

In my music player using the new Apple Music API(released May 12, 2016) in iOS 9 (swift, although I'm currently getting familiar with Objective-C as well), I can display information from a streamed song, but not the artwork. I am using MediaPlayer, UIKit, and StoreKit frameworks. I have been successful requesting authorization to AddToCloudMusicLibrary and MusicCatalogPlayback. I have success displaying Apple Music artwork from songs that I downloaded from the Apple Music app, as well as artwork from my personal song collection. I have seen other people with issues on this, with no luck...

在我诉诸于显示默认图像(无论如何对于错误处理而言是必需的)之前,还是尝试从人们那里再询问一个时间,或者从其他服务中提取信息.任何帮助将是巨大的!在我的代码中并不是真正的错误,因此除非有帮助解决此问题的方法,否则我不会显示它.

Just going to try asking one more time, for the people, before I resort to displaying a default image(which is necessary anyway for error-handling), or pull from an alternate service. Any help would be great! Not really an error in my code so I won't show it, unless requested to help solve this problem.

我第一次尝试发布代码...这是我在一个名为Authorization的快速文件中所拥有的.我是否需要在任何地方引用此代码,或者应该在AppDelegate文件中引用它?这是我的项目的唯一部分,我不确定100%.

My first attempt at posting code...Here is what I have in a swift file called Authorization. Do I need to reference this code anywhere or should it be in the AppDelegate file instead? This is the only part of my project I am not 100% sure of.

import StoreKit
import MediaPlayer
import UIKit

class AppleMusicPlayer: NSObject {

    let applePlayer = MPMusicPlayerController.systemMusicPlayer()

    func playID(productID: String) {
        SKCloudServiceController.requestAuthorization { status in
            let controller = SKCloudServiceController()
            controller.requestCapabilitiesWithCompletionHandler { capabilities, error in
                if capabilities != SKCloudServiceCapability.None {
                    MPMediaLibrary.defaultMediaLibrary().addItemWithProductID(productID) { entities, error in
                        self.appPlayer.setQueueWithStoreIDs([productID])
                        self.appPlayer.shuffleMode = .Songs
                        self.appPlayer.play()
                    }
                }
            }
        }
    }
}

推荐答案

这是当前Apple Music API中的错误.如您所述,不在用户库中而是从AM流式传输的歌曲不会返回专辑插图.

This is a bug in the current API for Apple Music. As you mentioned, songs that are not in the user's library but are instead streamed from AM will not return album artwork.

您应该在bugreport.apple.com上进行功能增强(您也可以在6个月前将其欺骗25413082).

You should file a feature enhancement at bugreport.apple.com (you can also dupe mine from 6 months ago 25413082 ).

与此同时,最好的选择是使用iTunes api来检索专辑插图,但是不幸的是,这并没有100%的时间返回正确的结果...

In the meantime your best bet would be to use the iTunes api to retrieve the album artwork, unfortunately this doesn't return the correct results 100% of the time...

这篇关于如何显示流式Apple Music的专辑插图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆