Get downloaded tracks when querying MPMediaItem and can't detect them

Hello,

We've a music app reading MPMediaItem.

We got items using MPMediaQuery. But we realized that some downloaded tracks from Apple Music were fetched too. Not all downloaded track but only those who were played recently.

Of course, since these tracks are protected with DRM we can't play them in our player.

It's weird to get them in our query because we added predicate in order to dont fetch protected asset and iCloud item

MPMediaPropertyPredicate(value: false, forProperty: MPMediaItemPropertyHasProtectedAsset)
MPMediaPropertyPredicate(value: false, forProperty: MPMediaItemPropertyIsCloudItem)

To be sure, we made a second check on each item we've fetched

extension MPMediaItem {
    public func isValid() -> Bool {
        return self.assetURL != nil && !self.isCloudItem && !self.hasProtectedAsset
    }
}

But we still get these items. Their hasProtectedAsset attribute always return false.

I dont know if it's a bug, but since we can't detect this items as Apple Music downloaded track, we can't either:

  • filter them to not add them in our application library

OR

  • switch on a MPMusicPlayerController.applicationMusicPlayer to allow the user to play them

I've run into this too. I'm also running into the opposite issue where tracks that are locally downloaded are not being included in the query results.

Get downloaded tracks when querying MPMediaItem and can't detect them
 
 
Q