Cannot read playbackStoreID property from MPMediaItem in Mac target

Running in a Mac (Catalyst) target or Apple Silicon (designed for iPad).

Just accessing the playbackStoreID from the MPMediaItem shows this error in the console: -[ITMediaItem valueForMPMediaEntityProperty:]: Unhandled MPMediaEntityProperty subscriptionStoreItemAdamID. The value returned is always “”.

This works as expected on iOS and iPadOS, returning a valid playbackStoreID.

import SwiftUI
import MediaPlayer

@main
struct PSIDDemoApp: App {
    var body: some Scene {
        WindowGroup {
            Text("playbackStoreID demo")
                .task {
                    let authResult = await MPMediaLibrary.requestAuthorization()
                    if authResult == .authorized {
                        if let item = MPMediaQuery.songs().items?.first {
                            let persistentID = item.persistentID
                            let playbackStoreID = item.playbackStoreID // <--- Here
                            print("Item \(persistentID), \(playbackStoreID)")
                        }
                    }
                }
        }
    }
}

Xcode 15.1, also tested with Xcode 15.3 beta 2.

MacOS Sonoma 14.3.1

FB13607631

Answered by gbuela in 789878022

I got a reply for my Feedback. Basically MediaPlayer as a legacy framework is unlikely to get patched for things like these and they suggested I switch to MusicKit.

Which I did! A lot of work though.

Accepted Answer

I got a reply for my Feedback. Basically MediaPlayer as a legacy framework is unlikely to get patched for things like these and they suggested I switch to MusicKit.

Which I did! A lot of work though.

Cannot read playbackStoreID property from MPMediaItem in Mac target
 
 
Q