getmusicbee.com

Support => Developers' Area => MusicBee API => Topic started by: e-motiv on July 04, 2011, 09:32:47 PM

Title: List of auto generated music urls.
Post by: e-motiv on July 04, 2011, 09:32:47 PM
While I await some kind of tag notification in the API ::), I thought I'd make a plugin that is a kind of auto-playlist.
Here's a self-explanatory example:

There is this  FM radio program site hat ONLY provides it's own radio Flash software, but I DO know their mp3 files are just urls with a date behind it (more or less).
e.g. http://myradiostation.com/somefilename-HiQ-20110704.mp3.
So, my wish would be for a list that auto generates this week's full of mp3's. 

But I don't know where to start. For example:
- How do I make a "menu item" on the left (e.g. an entry in a group (e.g. "MyEntry" under "Playlists", or a seperate group (on same level as "library", "playlists", "internet", "computer") ?
- Which functions control it? Are they Windows forms or so or is it MB specific ? (I am new to windows "engine" :-) )
- How to populate a list? And do I have to make their (double) click behavior and right menu myself or can I take the default from MB?
- ...
Looking at the API functions, I guess it' might not ready yet for that, but I would be most happy to be mistaken!  ;D
Also any suggestions that I am going about this the wrong way, are also welcome.

And if it would not be possible via the API in the near future, feel free to move this to the wishlist.

P.S. No worries, I have the permission from that radio station to use those files how I see fit (as long as I don't overload or st. like that). That program love their listeners, just are tied by the radio station's policy and budgets...
Title: Re: List of auto generated music urls.
Post by: Steven on July 04, 2011, 09:52:40 PM
with the current version of the api you can construct the "now playing list" only
NowPlayingList_Clear
NowPlayingList_QueueLast (probably the one you want to use)
NowPlayingList_QueueNext
Title: Re: List of auto generated music urls.
Post by: e-motiv on July 05, 2011, 10:09:46 AM
Thanks Steven.
I'll make my plugin with those for now.
Title: Re: List of auto generated music urls.
Post by: e-motiv on July 05, 2011, 12:17:52 PM
By the way, How do I make users command this?

I mean, I added this to "Initialise" for now, but how do I add this to a menu or shortcut or any other GUI element?
Title: Re: List of auto generated music urls.
Post by: Steven on July 05, 2011, 01:34:33 PM
there is MB_AddMenuItem but with the current MB version i only did a quick implementation to support boroda74's tag tools plugin.
I will make it a priority to get this sorted out for general usage and other API enhancements requested as a priority after bitmap skinning is done (hopefully this weekend)
Title: Re: List of auto generated music urls.
Post by: e-motiv on July 05, 2011, 04:01:30 PM
Great! Keep me posted.
Title: Re: List of auto generated music urls.
Post by: e-motiv on July 05, 2011, 05:36:39 PM
with the current version of the api you can construct the "now playing list" only
NowPlayingList_Clear
NowPlayingList_QueueLast (probably the one you want to use)
NowPlayingList_QueueNext
Hmm..Clear works, but the other 2 do nothing.

I am calling them all in method "Configure" as follows (1.2.4201):
Code: C#
mbApi.NowPlayingList_Clear();
mbApi.NowPlayingList_QueueNext("http://download.streampower.be/vrt/klara/31_KL110005QMIX-snip_hi.mp3");
mbApi.NowPlayingList_QueueLast("http://download.streampower.be/vrt/klara/31_KL110005QMIX-snip_hi.mp3");
Title: Re: List of auto generated music urls.
Post by: Elberet on July 05, 2011, 07:54:55 PM
The variable name "Uri" is somewhat misleading, I think. MusicBee accepts standard Windows paths for the PlayNow and Queue* commands (hint: those aren't URIs at all) and will actually refuse to open the same files when given as valid file:// URIs. MusicBee's Uri parameters are most likely more closely related to its database entries (which reference files on a local harddisk, after all) then actual URIs.

A clarification would be nice, tho, and I'd prefer if any exchange between MusicBee and plugins was using actual URIs. ;)
Title: Re: List of auto generated music urls.
Post by: e-motiv on July 05, 2011, 08:11:38 PM
Thanks, Elberet.
I wonder why Steven proposed them.

Anyway, so there is no way to add these URI(s)* anywhere?
* which are the radio streams of this topic (just in case  :P)
Title: Re: List of auto generated music urls.
Post by: Steven on July 05, 2011, 08:19:09 PM
there is no block on uri's as such but looking at the code i see there is a block that MB needs to know about the file beforehand (the usual way would be the file is already in the library or a playlist). I will address that when i look the APIs soon
Title: Re: List of auto generated music urls.
Post by: Elberet on July 05, 2011, 11:37:05 PM
That explains a lot. So, essentially, MusicBee shouldn't care whether I say
NowPlayingList_PlayNow("E:\\Temp\\test.mp3");
or
NowPlayingList_PlayNow("file:///E:/Temp/test.mp3");

Correct?
Title: Re: List of auto generated music urls.
Post by: Steven on July 09, 2011, 09:54:56 PM
I am calling them all in method "Configure" as follows (1.2.4201):
Code: C#
mbApi.NowPlayingList_Clear();
mbApi.NowPlayingList_QueueNext("http://download.streampower.be/vrt/klara/31_KL110005QMIX-snip_hi.mp3");
mbApi.NowPlayingList_QueueLast("http://download.streampower.be/vrt/klara/31_KL110005QMIX-snip_hi.mp3");
i have changed it so MB does not need to know about the files you are playing beforehand. However the way its implemented is the file tags are read at the point you queue the file which for web-based links could take up to a few seconds if MB does not already have the file cached. If you are queing one or two files then i guess that wont matter too much.
I do have an internal mechanism for loading file tags a little before each file plays but its not straight-forward for me to hook that into the API, so i will only do that if you say you really need it.
Title: Re: List of auto generated music urls.
Post by: e-motiv on July 12, 2011, 08:37:43 PM
Thanks, Steven.  I will look into that asap.

Another thing, (also for other people that might read this):
This "asap" above could be a rather bit longer than expected from now. Reason: Recently some smoke came from my laptop and I have to send it to repair (again :( ) (within guarantee luckily).
And I don't have a backup laptop, but this one on which I am writing on now which I can use only a very few times.

So, as you may all know, I am not demotivated, just kinda helpless and angry with Asus.

Oh yeah, here is some advice to everyone: NEVER, NEVER buy an Asus!  Support really s****! And service is rather slow! Even if there hardware settings are really attractive..
Title: Re: List of auto generated music urls.
Post by: e-motiv on November 06, 2011, 09:23:38 PM
I am back!
Yey! Although...waiting for 5 months to get money back from Asus repair service to be able to buy a new laptop and then only half of the money.
In short: NEVER BUY ASUS! (Hardware quality superb! Service and repair: Your hardware is outdated before anything happens!)

Anyway, it indeed seem to work now, Steven. Thanks! (Hook not needed..so far  ;) )


Some other things:
I installed 1.3.4321 (from 2.4218 or similar subversion number) and now the Plugins part of preferences doesn't refresh-load new plugins anymore after the first time.  You now have to close MusicBee to be able to see new plugins in the plugins folder. You may never have known it did refresh plugins before, but it was a huge developer benifit for me since I made a new plugin for each build (to test and try).
Now I have to close and restart MB after every build. 
Do you have any suggestions? Thanks.
Title: Re: List of auto generated music urls.
Post by: e-motiv on November 07, 2011, 11:19:28 AM
The project is getting some progress.
Now I would like to do some more UI integrating, but I don't understand all API funtions.
So,...
..is there a wiki or api explanation yet? If not, pitty...
..more specifically, how can I add
......panel with entries (like "radio stations") and how to control it?
......OR
......an item under "Library", "Playlists", "Internet" or my own division and how to control it?
......OR
......any other solutions where I can add a list with "URLGenerators" of which each (on click) queues a list of URL's in the "Now Playing"?

Thanks!
Title: Re: List of auto generated music urls.
Post by: Steven on November 07, 2011, 01:04:40 PM
right now the only way would you for you to open your own window (see boroda74's Advanced Plugins API as an example - you can see the source code for it)
There isnt any API support for adding panels directly to MB - i would be prepared to add that but not right now
Title: Re: List of auto generated music urls.
Post by: e-motiv on November 07, 2011, 03:14:54 PM
(EDITED twice)
Thanks.
I've been browsing his source for a while,  and finally found it, but it's too hard for me to implement anything in it (will cost too much time).
I will stick to the Menu Items for now.
For people possibly looking for the same, this is how to make a window (for now) (check boroda74 for skinning) :
Code
mbForm = (Form)Form.FromHandle(mbApi.MB_GetWindowHandle()); 
ownedForm.Text = "Radio Dig";
mbForm.AddOwnedForm(ownedForm);
ownedForm.Show();

Steven,
1. Any ideas about my previous post, about refreshing / loading new plugins  without closing MB?
2. Also, I would love it if API could make a new Dropdown  in Navigator Panel.   :P
3. And tertio, NowPlayingList_QueueNext does not work if the character '-' is inside the string. Does it have to be URL-encoded or bug?
EDIT: HttpUtility.UrlEncode does not encode "-" (dash)! So, maybe "dash" should be allowed and it's a bug after all?

Now it works with dash!!!???  Maybe Steven fixed it in a weekly build. Thanks if so!