# Music playback with Apple Music

**URL:** <https://community.metabrainz.org/t/music-playback-with-apple-music/692332>\
**Category:** ListenBrainz\
**Tags:** brainzplayer\
**Created:** [April 23, 2024, 10:50am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332 "2024-04-23T10:50:09Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [April 23, 2024, 10:50am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/1 "2024-04-23T10:50:09Z")

</div>

Good news everyone!

If you have an Apple Music account, you will be happy to know that you can now log in and play songs directly from ListenBrainz.

Head on over to [the music services page](https://listenbrainz.org/settings/music-services/details/) to sign in with Apple Music.

Arriving at the end of a one month trial myself, I will not have access for long and would really appreciate any feedback you may have on this new playback option.

Thank you !

---

<div class="post-metadata">

**Author:** ![fdsa](https://community.metabrainz.org/user_avatar/community.metabrainz.org/fdsa/32/75745_2.png) [@fdsa](https://community.metabrainz.org/u/fdsa)\
**Post date:** [April 24, 2024, 4:38pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/2 "2024-04-24T16:38:58Z")

</div>

Awesome!

1. It works!
2. I had to disable the YouTube integration to get it to be used. Ideally I’d want both enabled and have it fall back to YouTube if it doesn’t find the song on Apple Music

---

<div class="post-metadata">

**Author:** ![lenniepaine](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/l/94ad74/32.png) [@lenniepaine](https://community.metabrainz.org/u/lenniepaine)\
**Post date:** [April 24, 2024, 6:58pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/3 "2024-04-24T18:58:40Z")

</div>

Awesome, many thanks! That seems to work fine so far, but I just have started with it.

Just to understand this correctly - it is currently not possible to import listens from Apple Music? Will this be possibile in the future, or are there technical limitations preventing this?

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [April 25, 2024, 6:05pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/4 "2024-04-25T18:05:12Z")

</div>

Both of you, thanks for helping with testing!

@fdsa Yes that’s in the plans, having on that same settings page a way to choose the order in which the music sources are used.

@lenniepaine There is indeed a technical limitation unfortunately, Apple Music doesn’t provide a timestamp for the listening history, and we depend on that for everything.  
At the moment we don’t have a solution to remedy this lack of data and don’t have plans to record listens form Apple Music.  
However we can make it so that the tracks you play on the ListenBrainz website are submitted. It’s not currently active as I wanted more time for testing, but that’s the next step.

Similarly to the answer above, I’d like to implement settings to activate/deactivate listen submission for each music service separately.

---

<div class="post-metadata">

**Author:** ![fdsa](https://community.metabrainz.org/user_avatar/community.metabrainz.org/fdsa/32/75745_2.png) [@fdsa](https://community.metabrainz.org/u/fdsa)\
**Post date:** [June 2, 2024, 6:13pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/5 "2024-06-02T18:13:33Z")

</div>

I’ve been using this again a little the past few days, and I’m noticing that it’s frequently playing the wrong tracks, even when they’re available on Apple Music. I _think_ that used to work better.

E.g. this [ListenBrainz](https://listenbrainz.org/player/?recording_mbids=5e33d57e-3434-421b-ab65-246f54e42f2b) plays Brujería while the song is available on Apple Music: [‎La Clave&nbsp;– Titel von El Gran Combo de Puerto Rico&nbsp;– Apple&nbsp;Music](https://music.apple.com/de/song/la-clave/302888331)

This [ListenBrainz](https://listenbrainz.org/player/?recording_mbids=26a654d4-c528-4d39-90a2-28958d30c828) plays Sobredosis although the song is available [‎En Trance&nbsp;– Titel von Los Titanes&nbsp;– Apple&nbsp;Music](https://music.apple.com/de/album/en-trance/26107789?i=26107697)

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [June 3, 2024, 11:17am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/6 "2024-06-03T11:17:17Z")

</div>

Yep, I confirm I’m seeing the same thing, thanks for reporting the issue and for the details

In short, we play the first result from the search response we get from the apple music API, and in this case it turns out to be the wrong one, even though the correct one is in the results.

Irritatingly, running the same search terms on the apple music website, I can see from their internal search response that they get the correct result at the top of the list…  
So somehow, their API responses to third parties are biased in some way in order to return some other result they are pushing.

I have tried or will try a couple of things to improves the situation:

- Remove the album title from the search terms (this helped in the case of spotify search, and seems to maybe help here too). This fixes the second example “En Trance”, where the album name was “Sobredosis de amor y salsa” which resulted in only various matches for the song “Sobredosis” by the same band. Makes sense considering the search terms.

- Add another layer of processing the API response to see if any of the search results’ name matches the search term better. This is for your first example “La Clave”, where removing the album title did not fix the issue, and the expected song came in only as the third result. Doing a quick check to see if any of the results matches the expected song title could help in many cases.

---

<div class="post-metadata">

**Author:** ![sanojjonas](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sanojjonas](https://community.metabrainz.org/u/sanojjonas)\
**Post date:** [August 19, 2024, 10:44pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/7 "2024-08-19T22:44:44Z")

</div>

are any of these improvements allready done? because i still notice a bunch of incorrect plays when selecting some files (if you play the album “come on and feel the love” from the band “the love” some songs have a totally different artist)

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [August 20, 2024, 9:20am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/8 "2024-08-20T09:20:12Z")

</div>

They are indeed in place already, thanks for reporting more issues, I will take a look.

---

<div class="post-metadata">

**Author:** ![sanojjonas](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sanojjonas](https://community.metabrainz.org/u/sanojjonas)\
**Post date:** [August 20, 2024, 9:36am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/9 "2024-08-20T09:36:07Z")

</div>

if you test with [ListenBrainz](https://listenbrainz.org/album/5f2133c9-592c-44fe-ae9a-dae76de0d96b/)  
only the following songs are correct:

- donna
- fool
- hot fun
- daily grind

all the other songs are totally random artists

here is the link to the album in apple music

> **[Come on and Feel the Love by The Love on Apple Music](https://music.apple.com/us/album/come-on-and-feel-the-love/1682048064)**
>
> Album · 2023 · 10 Songs

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [August 20, 2024, 10:23am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/10 "2024-08-20T10:23:32Z")

</div>

Thanks for the extra details!

The Apple Music search API is terrible.  
Here are the results for the query terms “I’ve Got Love The Love”

```auto
Kendrick Lamar - LOVE. (feat. Zacari)
Kendrick Lamar - LOVE. (FEAT. ZACARI.)
Kendrick Lamar - i
Mos Def - Love
Jhené Aiko - LOVE

```

And here are the results for “Donna The Love”:

```auto
Donna Summer - I Feel Love
Donna Lewis - I Love You Always Forever
Lewis Capaldi - Someone You Loved
The Lumineers - Donna
Ozuna, Doja Cat & Sia - Del Mar

```

With the recent changes I added, the fourth result is selected as the song title is the closest to our search term (an exact match in this case).

I would add that for those same search terms, searching on the Apple Music website does not end up any better:

 ![image](https://community.metabrainz.org/uploads/default/original/3X/8/5/85568f6858973b8ef7e13da321991a6a8ac5753e.png)

I see two more potential avenues of improvement:

1. ~~see if there are ways to improve the search terms, for example specifying that “Donna” is the song title and “The Love” is the artist name. This is possible in other music APIs like Spotify, but I haven’t found documentation for that for apple music. I’ll keep digging that subject.~~
2. instead of getting the default 5 top results, get a lot more results and do some deeper comparison with song title and artist name to try to find a better match (don’t match “Donna” by “The Lumineers” if we are looking for a song by “The Love”). This could potentially lead to worse results in other cases so will have to be careful about it.

---

<div class="post-metadata">

**Author:** ![sanojjonas](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sanojjonas](https://community.metabrainz.org/u/sanojjonas)\
**Post date:** [August 20, 2024, 10:55am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/11 "2024-08-20T10:55:32Z")

</div>

could it help if the url to the album in apple music is in MB? can you then search for the song if you already have the album?

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [August 20, 2024, 11:06am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/12 "2024-08-20T11:06:37Z")

</div>

Yes, that would be ideal. We don’t currently have that set up (fetching that particular info from MB) but it is planned.  
Searching by ISRC is also available on some music services, and could be very useful for this use case.

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [August 20, 2024, 12:02pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/13 "2024-08-20T12:02:00Z")

</div>

> [@mr\_monkey](#):
>
> see if there are ways to improve the search terms, for example specifying that “Donna” is the song title and “The Love” is the artist name. This is possible in other music APIs like Spotify, but I haven’t found documentation for that for apple music. I’ll keep digging that subject.

Unfortunately, there is no way I could find to specify what part of the search terms are song title vs. artist name, or to search for exact matches, or any other way to improve the search results. 😡

So the Apple music API will search using every word of the search term, and return what it thinks are the top results (i.e. the most popular). You can imagine that there are many results where either the song title **or** album name **or** artist name contains “I’ve” **or** “Got” **or** “Love”… This is why there are so many unrelated results. Wrapping terms in quotes (like you would in Google) to search only for “I’ve Got Love” (rather than “I’ve” or “Got” or “Love”) also changes nothing.

Apparently, people’s solution is to use Google to search for “Apple Music song name artist name” and click the first result…  
Needless to say, not exactly an ideal solution for playing music in LB.

---

<div class="post-metadata">

**Author:** ![sanojjonas](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sanojjonas](https://community.metabrainz.org/u/sanojjonas)\
**Post date:** [August 20, 2024, 1:58pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/14 "2024-08-20T13:58:43Z")

</div>

and is it maybe possible to only look for the artist and then look deeper for the songs of that artist?

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [August 20, 2024, 2:27pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/15 "2024-08-20T14:27:26Z")

</div>

On their website, or for a single track, that wouldn’t be a problem.  
But with an API and the arbitrary data we have on LB, that means:

- One API call to search for the artist + find the right artist in those search results
- One API call to get the albums for that artist
- One API call **per album** to get its tracks, then check if any of the tracks matches the one we are looking for
- In the case of The Love with 20 albums that’s a potential 22 API calls just to play a single song

That can potentially be a lot of API calls for each song you are trying to play, with additional associated problems of resource consumption, API rate-limiting and quotas, all of that without even the assurance that you found the right artist in the first step  
The result would be an extremely wasteful and slow website and a user experience most likely on par with the current one (considering we still need to use the same 💩 search API)

---

<div class="post-metadata">

**Author:** ![sanojjonas](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sanojjonas](https://community.metabrainz.org/u/sanojjonas)\
**Post date:** [August 20, 2024, 8:19pm UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/16 "2024-08-20T20:19:14Z")

</div>

maybe you should try to look for the next song while te previous one is playing. as long as it doesn’t take longer than the length oof the song it won’t be an issue. only the first song will take a longer time before it starts…

---

<div class="post-metadata">

**Author:** ![mr\_monkey](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mr\_monkey](https://community.metabrainz.org/u/mr_monkey)\
**Post date:** [August 21, 2024, 10:10am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/17 "2024-08-21T10:10:43Z")

</div>

Something I can definitely think about, thanks for the suggestions!  
We could potentially consider that if playing from an album page, instead of searching for each track separately we could search for the album instead and, as you say, pre-load some of the information we will need to play following tracks.

---

<div class="post-metadata">

**Author:** ![sanojjonas](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sanojjonas](https://community.metabrainz.org/u/sanojjonas)\
**Post date:** [August 21, 2024, 10:47am UTC](https://community.metabrainz.org/t/music-playback-with-apple-music/692332/18 "2024-08-21T10:47:04Z")

</div>

i think you can also do that with playlist. i don’t see a shuffle or a way of chaning the order. if you load the upcomming 10 songs then i guess you are always safe, event if you skip a file.
