MPMediaItem changing properties
Asked Answered
Z

3

5

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?

Zettazeugma answered 7/6, 2012 at 7:0 Comment(0)
S
0

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

Stefanysteffane answered 25/6, 2012 at 22:13 Comment(1)
Thanx! I'm goes to trying jailbreak actionsZettazeugma
S
6

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.

Shivery answered 21/3, 2014 at 14:50 Comment(1)
This doesnt sync ratings or other properties over iCloud. Please check my answerDiscrown
D
3

@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

Discrown answered 22/9, 2018 at 8:51 Comment(5)
Your solution doesn't change the rating asked by the OP, it works just for the new like/dislike switch.Crider
@Crider you are right :) I hadnt yet implemented the APIs and checked the docs clearly. Updating answer. Seems there is no way to change Star Ratings correctly for items so they sync to the iCloud Music Library.Discrown
In fact, @sooper’s answer is working fine on the device, and the star rate is updated on the computer after sync.Crider
@Crider that is weird. I wasnt able to get it to work, would be happy if it eventually does! Did you sync with a PC you are saying? Maybe that works, but with iCloud Music Library it doesnt?Discrown
My own experience with this topic (non-icloud music). I can change the rating on the device, the rating is visible on the device, and also on the computer (mac in my case) after synchronisation wIth iTunes. That’s the way I change almost all my ratings for new purchases. I don’t have iCloud music and don’t need to have it, so I can’t say anything about this, sorry....Crider
S
0

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

Stefanysteffane answered 25/6, 2012 at 22:13 Comment(1)
Thanx! I'm goes to trying jailbreak actionsZettazeugma

© 2022 - 2024 — McMap. All rights reserved.