FB13364138
Post
Replies
Boosts
Views
Activity
Thanks for the reply! Maybe I'm missing something, but how can we pass the PlayParameters obtained from a Music item to MPMusicPlayerPlayParameters? Is there a way to convert between them?
I've also submitted FB9892700 about the missing artwork issue.
This is what I've found out so far:
@available(iOS 15, macCatalyst 15, *)
extension PlayableMusicItem {
func play() {
/// This works for me, but the artwork is blank
mpMediaPlayer.setQueue(with: [id.rawValue])
mpMediaPlayer.prepareToPlay()
/// This does not work, throwing the `9205` error code.
/// `[SDKPlayback] Failed to prepareToPlay error: Error Domain=NSOSStatusErrorDomain Code=9205 "(null)"`
Task {
musicPlayer.queue = [self]
try await musicPlayer.play()
}
/// This also doesn't work, throwing the same `9205` error code
let parameters = MPMusicPlayerPlayParameters(dictionary: ["id": id.rawValue, "kind": "song"])
guard let parameters = parameters else { return }
mpMediaPlayer.setQueue(with: MPMusicPlayerPlayParametersQueueDescriptor(playParametersQueue: [parameters]))
mpMediaPlayer.prepareToPlay()
}
private var musicPlayer: SystemMusicPlayer { .shared }
private var mpMediaPlayer: MPMusicPlayerController { .systemMusicPlayer }
}
And this is the result using the first method to load the playlist "Taylor Swift essentials":
@JoeKun I'd like to leave more info that I've discovered in the previous days
The "Add to playlist" commands from the Shortcuts application in Monterey do not seem to work either. I've setup a simple shortcut to add the current track library but it does not work.
I've also tried the Media Player API from Catalyst with MPMediaLibrary.addItem and that works perfectly, except it's hard to get the product ID for the current track. Do you know if there's an easy way to fetch the identifier for an MPMediaItem?
As a side note, MPMediaPlayer.currentItem always returns nil when playing a track not saved in the library, is it a Catalyst bug?
The ideal solution in the future would probably be to port MPMediaPlayer to non-Catalyst macOS with its full feature set, including MPMediaLibrary.
I'm also having troubles with this. I'm glad @JoeKun and the Music team are working on the issue. This is what I have found so far:
for tracks in AM's playlist, when the playlist is not added to library: duplicate current track to source "Library" or duplicate current track to first source works
for tracks in AM's playlist, when the playlist is added to library (in the sidebar): cannot add track to library, we can only add it to an user playlist with duplicate current track to user playlist "name of user playlist"; running duplicate current track to first playlist of first source succeeds but Music hangs needing a force quit (and at the next start the track is not added)
for tracks in AM's radio or with autoplay: cannot add track to library nor to user playlist; running duplicate current track to first playlist of first source succeeds but the track is not actually added, same if trying to add it to playlist: the command runs, but the track is immediately removed
I hope that this information will be useful and we will have a fix soon!