getmusicbee.com

Support => Developers' Area => MusicBee API => Topic started by: stax76 on February 28, 2017, 01:42:56 PM

Title: RatingChanged notification not working
Post by: stax76 on February 28, 2017, 01:42:56 PM
Case NotificationType.RatingChanged
                'output panel shows only that a thread has exited
                Debug.WriteLine("url: " + sourceFileUrl)
Case NotificationType.PlayStateChanged
                'prints to output panel as expected
                Debug.WriteLine(mbApiInterface.Player_GetPlayState().ToString)
Title: Re: RatingChanged notification not working
Post by: Steven on February 28, 2017, 06:12:20 PM
it looks like it was only done for when the rating is changed in the tag editor
The v3.0 patch version from the first forum topic is updated to include notification elsewhere
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 09, 2017, 01:26:50 AM
I confirm that the OP problem is solved (MusicBee_3_1_6454 when I first tested it).

However, I am wondering if the old scheme of NotificationType.RatingChanging & NotificationType.RatingChanged is preserved?
It has been a while that I worked on my plugin again, so I don't know when this change has been introduced, but..
..In the past, my plugin received both of them before the TagsChanged notification, but now only after. This results in the user having to wait until the song ends before getting (audio) feedback about his action, which is awkward. (I don't think it matters for TagsChanging, because that's immediate anyway.)
So, in short, is it possible to put the rating notifications back before TagsChanged notification?

See code below.


Code
rating = mbAPI.Library_GetFileTag(sourceFileUrl, MetaDataType.Rating);
rating = rating=="0,0"?"0":rating==""?"norating":rating;
DebugTimed("\tAbout to speak");
switch (type)
{
case NotificationType.RatingChanging:
//debug = " - Rating: " + rating;
//QueueAndPlay("ratingchanging"); //debug
ratingfrom=rating;
break;
case NotificationType.RatingChanged:
//debug = " - Rating: " + rating;
QueueAndPlay("ratingchangedfrom");
QueueAndPlay(ratingfrom);
QueueAndPlay("2"); //function not as the numbern but the word,  "to" :-)
QueueAndPlay(rating);
//Out("Test async playing"); WORKS
ratingfrom="unknown";
break;
case NotificationType.TagsChanged:
//debug = " - Rating: " + rating;
QueueAndPlay("changessaved");
break;
}
Title: Re: RatingChanged notification not working
Post by: Steven on September 09, 2017, 03:12:58 PM
comparing to v2.3 i cant see any obvious differences.
How exactly are you changing the rating? eg. in the tag editor, player panel, etc
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 09, 2017, 06:04:15 PM
In the playlist actually, with mouse hovering over the displayed stars (no context menu).
But now I tested it in the player panel too, same problem.
Also in the tag editor, same problem if you don't hit the save button on the right upper corner.
(Again it's only problematic when the track itself is playing in all cases.)

I'm not sure why it behaved differently now then ages ago. Maybe it was even before 2.3? Not sure when that was.
But I can't resolve it via mere code on my end I think, since I don't have the necessary event/info at exact moment when the user does the rating change action.
In any case, isn't it also just logical that the rating events happen immediately and not only after the track stops playing (and the tags are saved)? The user can know by experience that it has not been saved and there is a save event in any case after that, also as audio in my addon.

I'll add my latest private version of my addon here (https://www.dropbox.com/s/jjjqt1c7r3l6s33/Speak%20Back%200.1.145.zip?dl=0) to maybe better understand what I find not logical.
It registers the command "Speak Back - Show debug trace", so you can "keyboard-shortcut" that and get some debug info from the adddon, after some rating changes which you should then hear.
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 20, 2017, 04:43:10 PM
Friendly reminder..
Are you willing to change it, please?
Title: Re: RatingChanged notification not working
Post by: Steven on September 20, 2017, 08:23:59 PM
when saving a rating, MB should currently be sending
PluginNotifyType.RatingChanging
PluginNotifyType.TagsChanging
PluginNotifyType.TagsChanged
PluginNotifyType.RatingChanged

if that sequence is causing a problem i could change to:
PluginNotifyType.RatingChanging
PluginNotifyType.TagsChanging
PluginNotifyType.RatingChanged
PluginNotifyType.TagsChanged

would that solve the problem?
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 20, 2017, 09:49:07 PM
Yes, but only ìf RatingChanged triggers befòre the track stops playing
Let me illustrate by injecting a "stops playing".

PluginNotifyType.RatingChanging
PluginNotifyType.TagsChanging
PluginNotifyType.RatingChanged
<STOPS PLAYING>
PluginNotifyType.TagsChanged


---
For the record: That's what I have experienced so far, namely that TagsChanged only happens after the track stops playing.

PluginNotifyType.RatingChanging
PluginNotifyType.TagsChanging
<STOPS PLAYING>
PluginNotifyType.TagsChanged
PluginNotifyType.RatingChanged

Maybe because it has to be saved to the file? (Probably depends on setting to save rating in file.)
Title: Re: RatingChanged notification not working
Post by: Steven on September 20, 2017, 10:02:18 PM
no i wont do that.
I suggest you wait a small time (eg. 1 second) after RatingChanging is received if you need to query MB ie. MB updates its in-memory cache immediately
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 22, 2017, 04:05:25 PM
no i wont do that.
OK. I'll try your proposed workaround then.
But first, just in case this means anything:
RatingChanged looks superfluous to me now since the combination RatingChanging & TagsChanged seems to address all possible use cases for developers, but maybe I can't see all of them.
Anyway..
I suggest you wait a small time (eg. 1 second) after RatingChanging is received if you need to query MB ie. MB updates its in-memory cache immediately
That's helpful! Thanks!   I think this workaround solved it.
I thought the rating was only "query-able" after the RatingChanged event.
Thanks again.
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 22, 2017, 05:07:26 PM
I'm not sure if I should continue this on this topic now, but..
Is it possible that a keyboard "Rating Now Playing: * star"  does not trigger a RatingChanging event, only a TagsChanging and if so, is that how it should be?
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 26, 2017, 09:11:39 PM
Friendly reminder.
And I should say "hotkey", so..
Can you check if a rating changing hotkey triggers a RatingChanging event, Steven? Thanks.
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 27, 2017, 02:51:44 AM
Also, I just noticed, but when right-clicking on track and changing rating via context menu RatingChanging does NOT trigger. Can you fix that too please? Thank you.
Title: Re: RatingChanged notification not working
Post by: Steven on September 27, 2017, 08:37:16 PM
Also, I just noticed, but when right-clicking on track and changing rating via context menu RatingChanging does NOT trigger. Can you fix that too please? Thank you.
http://musicbee.niblseed.com/V3_1/MusicBee31_Patched.zip
Title: Re: RatingChanged notification not working
Post by: e-motiv on September 29, 2017, 12:13:39 PM
Confirmed fixed: hotkey, context menu
The tag editor (panel) still lacks it, but that's not important for me. Just FYI.
Thanks!!