AlKozin
AlKozin

Reputation: 916

MPMediaItem changing properties

I try to write Activator action for changing current song rating. I now that we can read MPMediaItemPropertyRating property and get rating. But how can we change it from app?

Upvotes: 5

Views: 1543

Answers (3)

user2239333
user2239333

Reputation:

@sooper's answer works for local MPMediaItems on the device. But iOS doesnt sync these to iCloud Music Library or Apple Music.

Seems there is no way to change 'Star' Ratings so they are synced to iCloud Music Library. Any setValue:forKey: attempts change the Star Rating only locally. Such changes may be overwritten by any future iCloud Music Library sync.

We can change 'Love' Ratings of our Apple Music catalog and iCloud Music Library, using Apple Music Web APIs as pointed out by @AMGuru here.

And below is the Apple Documentation for those APIs:

https://developer.apple.com/documentation/applemusicapi/ratings

Upvotes: 3

sooper
sooper

Reputation: 6039

You can change the rating of a MPMediaItem with the following line:

[mediaItem setValue:[NSNumber numberWithInteger:rating] forKey:@"rating"];

Works fine in iOS 7, cannot be sure for earlier versions.

Upvotes: 6

Klaas
Klaas

Reputation: 22773

According to the iPod Library Access Programming Guide "All media item metadata is read-only.".

Upvotes: 0

Related Questions