来自曲目 MPMediaItem 的专辑插图

Posted

技术标签:

【中文标题】来自曲目 MPMediaItem 的专辑插图【英文标题】:Album artwork from track MPMediaItem 【发布时间】:2018-11-28 21:38:40 【问题描述】:

我正在使用 Apple Music API 的 recent played endpoint,它返回最近播放的媒体资产列表。

然后我使用其中一个并在 MPMusicPlayerController 上播放。


        "id": "1437591818",
        "type": "albums",
        "href": "/v1/catalog/us/albums/1437591818",
        "attributes": 
            "artwork": 
                "width": 3000,
                "height": 3000,
                "url": "https://is2-ssl.mzstatic.com/image/thumb/Music118/v4/46/e9/60/46e9606c-59ec-1243-c377-2089c303dacf/00602577153884.rgb.jpg/wxhbb.jpeg",
                "bgColor": "000000",
                "textColor1": "faf0ee",
                "textColor2": "ecd0d3",
                "textColor3": "c8c0be",
                "textColor4": "bca6a9"
            ,
            "artistName": "Lil Wayne",
            "isSingle": false,
            "url": "https://itunes.apple.com/us/album/tha-carter-v/1437591818",
            "isComplete": true,
            "genreNames": [
                "Hip-Hop/Rap",
                "Music"
            ],
            "trackCount": 23,
            "isMasteredForItunes": true,
            "releaseDate": "2018-09-28",
            "name": "Tha Carter V",
            "recordLabel": "Young Money Records, Inc.",
            "copyright": "℗ 2018 Young Money Records, Inc.",
            "playParams": 
                "id": "1437591818",
                "kind": "album"
            ,
            "editorialNotes": 
                "standard": "Maybe more than any other rapper in history, Lil Wayne’s output is defined by franchises. An artist should be so lucky to sustain the kind of longevity that would allow for multi-volume phases the likes of Wayne’s <i>Dedication</i>, and <i>Da Drought</i> mixtapes, let alone the series that made him into a superstar, <i>Tha Carter</i>. Though Wayne was not without projects in between, some seven years were allowed to pass between the release of the fourth and fifth installments of the lattermost. Fortunately, Wayne has rewarded his fans’ patience with 23 tracks that speak to a number of his most storied eras.<br />\n“Mixtape Weezy,” as Jay-Z famously coined, is alive and well on songs like the Swizz Beatz-produced “Uproar,” Wayne blacking out over a reinterpretation of G-Dep’s 2001 hit “Special Delivery.” The nostalgia doesn’t stop (or peak) there, as Wayne and Snoop Dogg share space over a flip of Dr. Dre’s “Xxplosive” on “Dope N*ggaz,” while Mannie Fresh revisits the Cash Money golden-era bounce of Juvenile’s “Ghetto Children” for “Start This Shit Off Right.” There are nods to the experimental Wayne of the <i>I Am Not A Human Being</i> projects (“Don’t Cry,” “Mess”) and also the rapper’s under-heralded pop wizardry (“Famous,” which features his daughter Reginae as hook singer), and even a love song built on a gospel sample, “Dope New Gospel.” In all, <i>Tha Carter V</i> is an album for anyone who’s missed Wayne—no matter which Wayne they’d missed.",
                "short": "Weezy F Baby, and the F is for finally."
            ,
            "contentRating": "explicit"
        
    ,

每当我想访问当前播放内容的元数据时,我都可以使用nowPlayingItem 属性获取它,该属性返回专辑中当前曲目的 MPMediaItem。

此 MPMediaItem 的艺术作品属性为空,因此我想访问专辑的艺术作品。我可以获取albumPersistentStoreId(例如3911653000682848550),并使用它通过Apple Music API请求专辑信息:

https://api.music.apple.com/v1/catalog/us/albums/3911653000682848550

但这会返回“找不到资源”错误消息。

使用搜索端点 (https://api.music.apple.com/v1/catalog/us/search?term=the+carter+v&limit=2&types=artists,albums) 或最近播放的原始端点,我看到这些返回的专辑 ID 与我在 albumPersistentStoreId 属性中得到的不同。如何从 MPMediaItem 获取正确的专辑 ID?

【问题讨论】:

【参考方案1】:

您可以使用 MPMediaItem 的播放存储 ID - 从 API 请求曲目信息并从那里获取专辑封面。

【讨论】:

以上是关于来自曲目 MPMediaItem 的专辑插图的主要内容,如果未能解决你的问题,请参考以下文章

利用iTunes给MP3添加专辑插图

如何在 Spotify 上播放专辑中的曲目,以便之后使用 Spotify App Remote SDK for Android 播放专辑的下一首曲目?

Spotify App API:播放专辑中的特定曲目

iOS:从 iPod 库中获取和显示专辑插图

如何按专辑中的曲目数量过滤此歌曲

获取带有 MusicBrainz ID 的专辑曲目列表