Author Topic: MusicBee API  (Read 176297 times)

MiDWaN

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

MiDWaN

  • Jr. Member
  • **
  • Posts: 61
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
  • Hero Member
  • *****
  • Posts: 28737
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: 61
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: 61
@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
  • Hero Member
  • *****
  • Posts: 28737
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
  • Hero Member
  • *****
  • Posts: 28737
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