Author Topic: MusicBee API  (Read 285410 times)

MiDWaN

  • Jr. Member
  • **
  • Posts: 78
OK, thanks for the feedback.
I'll notify the users accordingly.

MiDWaN

  • Jr. Member
  • **
  • Posts: 78
1) Save Playlists. There are currently GetPlaylists() and GetPlaylistFiles() which are already working, but is there a call I can use for saving them?
actually all the functions you need are there eg.
Playlist_CreatePlaylist(string folderName, string playlistName, string[] filenames)
and various other Playlist_xxxx functions to adjust the playlist files

Coming back to this again:
I can instantiate a Playlist_CreatePlaylist delegate, but isn't that used for Creating a new Playlist inside MusicBee? What I'm looking for is to get a notification when a MusicBee Playlist is created, so I can send the same playlist to Subsonic.
Is there any notification triggered when the user creates a new Playlist from MusicBee? I couldn't find one in the list of Notification Types at least.

Or is there another way that I'm missing to handle this?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
i will add these notifications to the API for the next v3.3 update
Code
    PlaylistCreated = 37
    PlaylistUpdated = 38
    PlaylistDeleted = 39
    PlaylistMoved = 40

this patch version has the change if you want to test it:
https://getmusicbee.com/patches/MusicBee33_Patched.zip
unzip and replace the existing musicbee files
Last Edit: March 03, 2019, 08:35:24 PM by Steven

MiDWaN

  • Jr. Member
  • **
  • Posts: 78
i will add these notifications to the API for the next v3.3 update
Code
    PlaylistCreated = 37
    PlaylistUpdated = 38
    PlaylistDeleted = 39
    PlaylistMoved = 40

this patch version has the change if you want to test it:
https://getmusicbee.com/patches/MusicBee33_Patched.zip
unzip and replace the existing musicbee files

Thanks, I'll test it and get back with results as soon as I can.

MiDWaN

  • Jr. Member
  • **
  • Posts: 78
@Steven
That seems to work, thank you. :)

Some things I noticed:
- When a new Playlist is Created in MusicBee, there are 3 notifications triggered in a sequence:
1) PlaylistCreated is triggered as soon as the new Playlist window opens up, it contains the default Playlist name ("Playlist").
2) PlaylistUpdated is triggered after the OK/Save button is pressed in the new Playlist window, still contains the default name (even if the user renamed it)
3) PlaylistMoved is triggered right after that, containing the final name given to the playlist.

For my purposes I can just listen for the 3rd one for "Create Playlist" because I need to get the name given to the playlist, so it's no big deal.
However, what's the point of the 2nd notification? That's a bit tricky because UpdatePlaylist could also mean that some tracks got added/removed, but if it's also triggered when a new playlist is created, you don't really know which scenario you've picked up...

Is that by design for some reason?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
There are multiple methods of creating a playlist, which can involve just one step. The way you choose involves 3 steps although that might not seem obvious to you as there are no files involved in each step for the method you chose.
I advise to check for all events and not assume PlaylistMoved as the last one

exscape

  • Newbie
  • *
  • Posts: 5
I believe I've found a bug in the NowPlayingList_QueueFiles* functions. If the track path has a # sign in it, anything after is ignored by MusicBee (basically treated like a comment), so it can't find the file, and a (!) shows up in the Upcoming tracks list.
For example, if I call

Code
List<string> tracks;
...
tracks[0] = "file://D:\\Music\\Music\\Compilations\\Metal Hammer #200 A Tribute to Dimebag Darrell\\04 Walk.mp3";
mbApiInterface.NowPlayingList_QueueFilesNext(tracks.ToArray());

... the API returns true, but the track can't be played and is silently ignored if I skip to the next track.
If I double click the track, I get a confirmation dialog:
"The source file for track 'Metal Hammer ' could not be found. Would you like to locate it?
D:\Music\Music\Compilations\Metal Hammer

The same code has worked flawlessly for a month or so now, but always fails on paths containing #.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
It uses the .Net Uri.TryCreate function but I agree its not working now.
I havent changed anything so I guess a recent .NET update changed the behaviour
I suggest using this format:
Code
D:\Music\Music\Compilations\Metal Hammer #200 A Tribute to Dimebag Darrell\04 Walk.mp3

Mugwump

  • Newbie
  • *
  • Posts: 5
Hi,

I noticed there is a release candidate for musicbee 3.3 which is compatible with dotnet framework 4.6.1. This version of dotnet framework is compatible with netstandard 2.0 assemblies (https://docs.microsoft.com/en-us/dotnet/standard/net-standard). Will music bee be able to work with plugins that are compiled as netstandard 2.0 class libraries?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
yes, and no need to recompile them using 4.6.1

MiDWaN

  • Jr. Member
  • **
  • Posts: 78
Hi Steven,

I'm having trouble getting the Rating I've set on a track, in order to send it to the Subsonic server. It always seems to return "0" as rating, which is not what I've set.

Specifically, the call I'm using is this:

Code
var rating = Subsonic.GetFileTag(sourceFileUrl, Interfaces.Plugin.MetaDataType.Rating);

And GetFileTag is defined as such:
Code
public static Interfaces.Plugin.Library_GetFileTagDelegate GetFileTag;

A similar call to get the Starred/Love setting of a track, works as expected:
Code
var starred = Subsonic.GetFileTag(sourceFileUrl, Interfaces.Plugin.MetaDataType.RatingLove);

Is this a bug in MusicBee's Interface, or am I missing something?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
its best you use the rating scale 0-100, with no decimal separator
if you use 0-5, you might run into issues with the decimal separator symbol for half ratings
looking at the code it looks to me like MB returns the rating on the 0-5 scale

MiDWaN

  • Jr. Member
  • **
  • Posts: 78
I wouldn't have a problem either way (Subsonic server uses 0-5 internally, with 0 being no rating set), but I only get "0" back from MB in my tests.

I've hooked that GetFileTag to the TagsChanged notification type, and it does trigger when I change a rating on a track in MB. But regardless what rating I set it to, I always get back "0" from the GetFileTag() call.

The RatingLove tag instead, gives me the correct value. I have that one in the same location as well.

Here's a more complete code listing in case it helps:

Code
public void ReceiveNotification(string sourceFileUrl, Interfaces.Plugin.NotificationType type)
{
    switch (type)
                {

                  ...
                    case Interfaces.Plugin.NotificationType.TagsChanged:
                        var rating = Subsonic.GetFileTag(sourceFileUrl, Interfaces.Plugin.MetaDataType.Rating);
                        var starred = Subsonic.GetFileTag(sourceFileUrl, Interfaces.Plugin.MetaDataType.RatingLove);
                  ...

From the above code, "rating" is always "0" when retrieved but "starred" gets the proper expected value when set.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
you should listen for:
            RatingChanging = 15,
            RatingChanged = 12,

if you still cant get it to work i wont be able to help further

MiDWaN

  • Jr. Member
  • **
  • Posts: 78
Even if I explicitly listen for those events instead (RatingChanging, RatingChanged), when I call GetFileTag() from them for the specific source file, the rating that comes back is always "0" (as a string, so it's not a conversion problem).

Is GetFileTag the right way to get the Rating?