Author Topic: RatingChanged notification not working  (Read 5559 times)

stax76

  • Jr. Member
  • **
  • Posts: 28
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)

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33483
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

e-motiv

  • Full Member
  • ***
  • Posts: 188
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;
}
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33483
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

e-motiv

  • Full Member
  • ***
  • Posts: 188
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 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.
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

e-motiv

  • Full Member
  • ***
  • Posts: 188
Friendly reminder..
Are you willing to change it, please?
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33483
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?

e-motiv

  • Full Member
  • ***
  • Posts: 188
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.)
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33483
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

e-motiv

  • Full Member
  • ***
  • Posts: 188
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.
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

e-motiv

  • Full Member
  • ***
  • Posts: 188
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?
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

e-motiv

  • Full Member
  • ***
  • Posts: 188
Friendly reminder.
And I should say "hotkey", so..
Can you check if a rating changing hotkey triggers a RatingChanging event, Steven? Thanks.
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

e-motiv

  • Full Member
  • ***
  • Posts: 188
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.
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33483
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

e-motiv

  • Full Member
  • ***
  • Posts: 188
Confirmed fixed: hotkey, context menu
The tag editor (panel) still lacks it, but that's not important for me. Just FYI.
Thanks!!
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig