PDA

View Full Version : JukeBox Plugin



joecru
2004-09-13, 08:35 PM
Hi Guys,

Can anyone give me help ,on adding a pgn up/down function to the Jukebox Plugin.So that selecting music files is quicker.
I downloaded Sharp Devel tool and had a look at the Jukebox Plugin.Under the JukeboxTasks.cs file part of the code had pgn functions. Is this where I can add the above functions
and then re compile the jukeboxtask.cs file. I've only started reading C Programming stuff. See below for the section of the code.


case Keys.PageDown:
userTopIdx += MAX_ITEMS;
if (userTopIdx >= userTracks.Count - MAX_ITEMS)
{
userTopIdx = userTracks.Count - MAX_ITEMS;
userSelIdx = userTracks.Count - 1;
}
else
{
userSelIdx = userTopIdx;
}
break;
*/
/*
case Keys.PageUp:
userTopIdx -= MAX_ITEMS;
if (userTopIdx < 0)
{
userTopIdx = 0;
}
userSelIdx = userTopIdx;
break;

Is this the right section, (if you can make it out), or am I barking up the wrong tree?

Regards
Joe

sub
2004-09-13, 09:51 PM
Yes, this is the page up/down code.

It looks to be generally correct, but he's currently got it commented out, so I suspect there may be a lurking bug. Remove the comment delimiters (/* and */) and give it a go.

joecru
2004-09-13, 11:58 PM
Hi Sub,

Thanks for the reply.
When it is compiled what will the file extension .cs have changed too? Will I need to do anything else to the file?

Regards
Joe

colin
2004-09-14, 12:04 AM
Hey joecru,

did you import the Jukebox plugin? In the projects window you'll need to add to the references the GBPVRPublic.dll.

Then you may want to adjust the project options and tell it where you want to place the .dll. And finally double check it will create a .dll for you.

Sharpdevelop is very good,

Cheers,
Colin.

joecru
2004-09-14, 12:14 AM
Hi Colin,

I am new to this, so keep me right. I made the changes within *notepad, as Sub mentioned above.I started Sharp Dev picked File option ,then open new file which was jukeboxtask.cs,then picked the run option.I am not sure where the compiled file is . Have I done it right?

Regards
Joe

colin
2004-09-14, 01:54 AM
Hey joecru,

to be honest, the simplest way to work on the jukebox plugin is extract its contents to a folder.

Then start up sharpdevelop. From the File menu choose to import a project and navigate to the jukebox plugin you just extracted. It should list a .sln (VSN project).

Import this and it will setup everything for you. Once you get this far you will see all the files associated with the project on the left in a projects window.

This is where you need to add in the references to the GBPVR*.dll libraries, then look through the project options and make sure it is outputing your new jukebox .dll into the right place.

then you can doubleclick on the jukeboxtask.cs file from the project file listings and edit this. Provided you have done the above then you can build it and use it in GBPVR:)

Your can use notepad, but you will need to know how to use the c# compiler and the associated flags. I would start with sharpdevelop then learn the manual while for compilation,

cheers,
Colin.

joecru
2004-09-14, 09:15 AM
Hi Colin,

What do you mean by the following,

This is where you need to add in the references to the GBPVR*.dll libraries, then look through the project options and make sure it is outputing your new jukebox .dll into the right place.

What are the References, and what should the Output dir be?

Regards
Joe

colin
2004-09-14, 11:40 AM
You need to make reference to the GBPVRPublic.dl library as this is how you tie you project into GBPVR.

I'm not sure of your programming background but basically this is linking to another library which contains classes which you need.

If you have imported the jukebox plugin, on the left there should be a projects window. If not got to View|Projects menu and display it.

You should now have a tree menu in this window with something like

- Combine 'Jukebox Plugin'
+ Jukebox Plugin

Expand the Jukebox plugin branch and this will list all the files/references/resources associated with the project.

Right mouse click over References, then go to the .Net Assembly Browser. Here there is a Browse button. Click on this and naviage to GBPVRPublic.dll.

This should now be listed as a reference in your project. Sharpdevelop now nows to "reference" or "link" to this library during compilation.

Now go to Project|Project Options on the menubar. Click on Configuration and you will see Output for debug builds and Output for Release builds. This determines where the "to be created JukeboxPlugin.dll" will be placed. If it is empty it will be created with your project. You can put in the location of GBPVR plugins and automaticlly place it in the plugins directory.

Hopefully this is clearer:)

Cheers,
Colin.

tkgafs
2004-09-14, 07:45 PM
thanks to colin and sub for the explanations.

page up and down seem to work fine on the jukebox plugin now

but what button would they be on the mvp remote ?

tkgafs

colin
2004-09-14, 07:56 PM
I wonder if the code was commented out for this reason and not because the code was not working?

Are the skip forward/skip backwards buttons enabled for anything here?

Colin.

tkgafs
2004-09-14, 09:05 PM
yes the skip buttons seem to be working I think in the code they are called Keys.Right and Keys.Left and certainly they work on the remote.

I moving on from this to another small amendment to the jukebox code

I want to skip indexing a folder or its subfolders if a file called noindex.txt exists in the folder.

I have added the following code

string NoIndexName = curDir + "\\noindex.txt";
if ( System.IO.File.Exists(NoIndexName))
{
return;
}

to the function PopulateDB at about line 586 of the code

this works fine but with one small problem although the folder has not been indexed, it is still listed in the display although if you enter it there are no tracks to select from.

Would you have any idea how to supress it from the display

As I have never written C# in my life before I am really struggling

throughout the code there are bits like dbDirs.Enqueue and dbDirs.Dequeue is this some form of pushing array elements on and off a stack ?

is there any C# language reference manuals that are available for download ?

thanks in advance

Tkgafs

tkgafs
2004-09-14, 09:57 PM
Where can I find out what each button on the mvp remote equates to in coding terms.

so that I can add the page up/down remote buttons to the jukebox plugin using something like the yellow + blue buttons

tkgafs

Tobias
2004-09-14, 11:47 PM
Did you add your code in the very top of the method? But still, I think that the PopulateDB method only adds MP3:s to the JukeBox queue and is not responsible för the file listing (may be wrong here)...

Im having a hunch that the referenced FileList (FileListSelectionTask) has got something to do with this. Maybe this code in the method "render" ?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Render the file listing..
FileList.Render&#40; g &#41;;
NowPlaying.Render&#40; g &#41;;[/QUOTE]

colin
2004-09-15, 12:20 AM
Hey tkgafs,

dbDirs.Enqueue and dbDirs.Dequeue are functions to interact with a Queue (FIFO - first in first out). What appears to be happening is the code scans the music directories defined in the config section. It adds these to its queue which is processes in chunks. Sub added a helper function Logger.Verbose(&quot;enter string&quot;) which you could use to put into functions to print out information.

Just like you would do in C, except you would use printf(); Logger.Verbose puts information into one of the logs files.

Use this to trace functions to track down where you need to put you test so as not to list that directory,

cheers,
Colin.

tkgafs
2004-09-15, 12:37 AM
I tried the logger.verbose but couldn&#39;t find anything in any of the logfiles which puzzled me.

Is there something like a #define which needs turned on get logging to write stuff to the logfiles ?


the code certainly seems a bit cryptic in how it works,

I tried adding my little bit of code to the addmusicdir function originally as I assumed that that would be were the directories were originally added as the enqueue facilty is called then,
but it didnt seem to work so then I tried populatedb function which certainly works but as I said I cant fathom out where the dirs are held in an array for displaying on the screen

All this effort just because my wife hates &quot;Henry Cow&quot; and doesn&#39;t want them popping up unannounced as it were

http://gbpvr.com/iB_html/non-cgi/emoticons/wink.gif

thanks for all your help so far

colin
2004-09-15, 12:57 AM
Actually now that you mention it i&#39;m not sure where the Logger.Verbose messages are going. I&#39;ll ask Sub about that.

So the path i see so far is

public JukeboxTask()
--&#62; FileList.AddMusicDir( strs[i] ); - this adds the top level music dirs defined in config app.
----&#62; dbDirs.Enqueue( name ); - this adds the top levels to the Queue for processing.

I think you are looking in the correct place you are just going to need to figure out what it is doing. To me this area looks interesting from PopulateDB

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
foreach &#40;string dir in dirs&#41;
{
allTracks.Add&#40; new Track&#40; dir, true &#41; &#41;;
dbDirs.Enqueue&#40; dir &#41;;
}[/QUOTE]

To me it looks like, for example, the directory &quot;C:&#92;Music&quot; is passed to PopulateDB. This then looks for all tracks in this directory plus all sub directories. The code i have highlighted I suspect adds directories like &quot;C:&#92;Music&#92;Unwanted Album&quot;

Colin.

tkgafs
2004-09-15, 09:18 PM
ok I have worked it out I think

to skip a folder in the jukebox create a file called noindex.txt in the folder you wish to omit from indexing. If this file is present then no files from this folder or any sub folders will be indexed, so they will not play in the jukbox


and change the following two functions in jukeboxtask.cs

change UpDateDirlist to the following

public void UpdateDirList()
{
Logger.Verbose(&quot;UpdateDirList:&quot;);
userTracks.Clear();

string userPath = userDir;

foreach ( Track track in allTracks )
{
string NoIndexName = track.Path + &quot;&#92;&#92;&quot; + track.Name + &quot;&#92;&#92;noindex.txt&quot;;

if ( System.IO.File.Exists(NoIndexName))
{
Logger.Verbose(&quot;UpdateDirList: found &quot; + NoIndexName);
}
else
{
if ( track.Path == userPath &amp;&amp;
track.Name &#33;= &quot;&quot; )
{
userTracks.Add( track );
}
}
}
}


and add the following few lines into the function PopulateDB straight after the follwing two lines

string[] files = System.IO.Directory.GetFiles( curDir, &quot;*&quot; ); string[] dirs = System.IO.Directory.GetDirectories( curDir, &quot;*&quot;);

/*
* new code follows
*/

string NoIndexName = curDir + &quot;&#92;&#92;noindex.txt&quot;;
if ( System.IO.File.Exists(NoIndexName))
{
return;
}


hope this helps some of you

tkgafs

joecru
2004-09-15, 10:47 PM
Hi Colin,

I followed your instructions and I now have a set of files in a dir called Newjukebox. In the dir there are a number of files.
ie:- GBPVRPublic.dll, jukeboxconfigform.cs, but I don&#39;t have a jukebox.dll file.The GBPVRPublic seems smaller than the one thats in the &#92;GBPVR&#92;Plugins&#92;. I am not sure what to do with the recompiled files.Do I need to rename extensions to .dll?

Regards
Joe

colin
2004-09-15, 10:59 PM
Need to check with Sub which GBPVRPublic.dll to link to.

Anyway, you will not have a jukebox.dll listed in the project window..

If you go to the menu bar and &quot;Project &#124; Project Options&quot;

you should get a Project options dialog window. Click on configurations and have a look a the &quot;Output&quot; section for both debug and release configurations. there is a section on the right where you can choose the location for your newly created library.

- You want the compile target to be library
- set the assembly name to the name of your .dll (do not add the .dll extension)
- set the output path to the location where you want to create the new .dll

Do that for both debug and release. and ok out of all that. Now you can eith er build this as debug or release - the choice is yours.

HTH,

Colin.

sub
2004-09-16, 08:16 AM
Quote[/b] ]I followed your instructions and I now have a set of files in a dir called Newjukebox. In the dir there are a number of files.
ie:- GBPVRPublic.dll, jukeboxconfigform.cs, but I don&#39;t have a jukebox.dll file.The GBPVRPublic seems smaller than the one thats in the &#92;GBPVR&#92;Plugins&#92;.
The safest bet is to copy the GBPVRPublic.dll from c:&#92;program files&#92;devnz&#92;gbpvr into the plugins directory. The older one is likely there because it was included in one of the plugin zip files you downloaded.

joecru
2004-09-16, 09:22 AM
Thankyou Guys for your excellent instructions.

I have the PGN UP/DOWN Functions working with the PC Jukebox. But it dosen&#39;t seem to be working with the MVP.
I noticed in the code CASE KEYS can I use these so that the MVP has the PGN functions. Say asign RED button PGN/up,and
YELLOW button PGN/down,on the MVP remote?

Regards
Joe

tkgafs
2004-09-16, 09:49 AM
Joe,

I was wondering exactly the same thing,

but I dont know what the coloured keys would be called in the code.

if you look at the logs when you press them they send the following

red 36,green 37,yellow 38 and blue 39

elsewhere in the code there is a bit where Keys.G is used to automatically skip to the whats playing screen and it does seem to work, so I thought that the keys might be called

Keys.R *= red, Keys.Y = yellow Keys.B = Blue and Keys.G = green

but if you also notice these keys are also used in the searching code presumably they are the keyboard keys when you are searching from the keyboard when running on the PC

So I&#39;m not sure if it would work as the case statement would encounter these values before page up / down code

can anyone tell us how to code for these inside plugins

are all the buttons, what they return and what their name is defined as inside plugin code defined anywhere.

I have had a look at the source of most of the plugins but none seem to use the coloured remote keys

Tkgafs

joecru
2004-09-16, 10:17 AM
Hi Tkgafs ,

If you look at the following code it relates to CASE KEYS etc I wonder is it here we can add the PGNKeys.

/// &lt;summary&gt;
/// Is called by GBPVR in response to a key being pressed while this
/// task is active. The task should return true if it has performed some action
/// as a result of the key press - which will inturn cause the task to be render()&#39;d
/// &lt;/summary&gt;
public bool OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
// Green key skips to now playing list immediately.
Keys.G )if ( e.Control &amp;&amp; e.KeyCode ==
{
mode = 1;
return true;
}

// Don&#39;t use Control or Alt keys..
if ( e.Control &#124;&#124; e.Alt ) return false;

slideDelay = DateTime.Now.AddSeconds(10);

// Shuttle Remote:
// Keys.MediaNextTrack;
// Keys.MediaPreviousTrack;
// Keys.MediaPlayPause;
// Keys.MediaStop;
// Keys.Prior; --- PG +
// Keys.Next; --- PG -
// Keys.VolumeUp;
// Keys.VolumeDown;
// Keys.LWin; --- &quot;windows key button between Vol+/- &amp; PG+/-
// Keys.Menu; --- &quot;double window icon above volume key&quot;

switch (e.KeyCode)
{
case Keys.Menu: // Shuttle Remote: double window icon above Vol+ key
case Keys.Escape:
// return to main menu
PluginHelperFactory.getPluginHelper().ReturnToMain Menu();
return true;
};

if ( mode &#33;= 0 )
{
mode = 0;
return true;
}
else
{
// Pass event to File List also..
return FileList.OnKeyDown( e );
}
}[QUOTE]

Its hard to make out but if you look at the above code, as you suggested Keys.G he has controlling the now play list which is the Green key on the MVP Remote.

Regards
Joe

tkgafs
2004-09-16, 11:28 AM
Joe,

I have to admit I&#39;m not really sure how the plugin all hangs together.

the code you display above is from the function onkeydown in the class JukeboxTask

but the function onkeydown also exists in the class FileSelection

where the function uses far more Key.? codes in the case statements

it is also in this version of the function that the page up and down code is invoked so I thought that we would need to put the Keys.R and Keys.Y in at the same point as the Keys.PageUp and Keys.PageDown

but as I said within the same switch block these definition [Keys.R and Keys.Y ] are already used before the page up down case is encountered, I&#39;m guessing that they are actually the alphabetic keys on the keyboard when you are running on the PC rather than on the MVP

I have never programmed anything like this before and have to admit I cant understand how we can have two functions with the same name in different areas of the code, when and how does each function get called ?

I&#39;m doing this from work just now so cant actually test anything but will try and test a couple of things tonight

tkgafs

colin
2004-09-16, 02:33 PM
Quote[/b] ]I have never programmed anything like this before and have to admit I cant understand how we can have two functions with the same name in different areas of the code, when and how does each function get called ?

What it looks like is an interface has been defined and in two different classes there is key handling code. depending on what the jukebox is doing will determine what is happening. Remember this is OO design so if the you a C programmer (or any other sequential language) its difficult to get your head around this.

In the Fileselection buttons do one thing, in the jukebox buttons do other things. If you are having trouble visualising it, try drawing it on paper,

cheers,
Colin.

sub
2004-09-16, 05:34 PM
Red : Ctrl-R
Green : Ctrl-G
Blue : Ctrl-B
Yellow : Ctrl-Y

When you&#39;re checking for these keys, you should also check control has been press...
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
case System.Windows.Forms.Keys.R&#58;
if &#40;e.Control&#41;
{
// do something
}
...[/QUOTE]

colin
2004-09-16, 07:42 PM
I actually only got around to trying this plugin today. It is very good. Kudos tot he author.

Colin.

colin
2004-09-16, 09:08 PM
I&#39;m looking into adding a screen saver of sorts for this plugin, unless someone has done it or is doing it?

Colin.

tkgafs
2004-09-16, 10:35 PM
Quote[/b] (colin @ Sep. 16 2004,21:08)]I&#39;m looking into adding a screen saver of sorts for this plugin, unless someone has done it or is doing it?

Colin.
Colin,

I&#39;d be very grateful for a screen saver for this plugin, and yes I agree this plugin is very good.

Tkgafs

tkgafs
2004-09-17, 12:42 AM
Ok I now have through a process of trial and error got the red and yellow buttons on the mvp remote acting as page up and page down respectivly

I&#39;m sure there is a better way of doing it but this works

in the function OnKeydown in the class JukeBoxTask [ which all key + button presses go through ]

add the following code after the code for the green button but before the comment // Don&#39;t use Control or Alt keys..
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
// red button used for page up
if &#40; e.Control &amp;&amp; e.KeyCode == Keys.R &#41;
{
return FileList.OnKeyDown&#40; e &#41;;
}
// yellow button used for page down
if &#40; e.Control &amp;&amp; e.KeyCode == Keys.Y &#41;
{
return FileList.OnKeyDown&#40; e &#41;;
}
[/QUOTE]
in the function OnKeyDown in the class FileSelectionTask

encase the large switch block with the following code
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
// yellow button used for page down
if &#40; e.Control &amp;&amp; e.KeyCode == Keys.Y&#41;
{
userTopIdx += MAX_ITEMS;
if &#40;userTopIdx &#62;= userTracks.Count - MAX_ITEMS&#41;
{
userTopIdx = userTracks.Count - MAX_ITEMS;
userSelIdx = userTracks.Count - 1;
}
else
{
userSelIdx = userTopIdx;
}
}
// red button used for page up
else if &#40; e.Control &amp;&amp; e.KeyCode == Keys.R &#41;
{
userTopIdx -= MAX_ITEMS;
if &#40;userTopIdx &#60; 0&#41;
{
userTopIdx = 0;
}
userSelIdx = userTopIdx;
}
else
{
switch &#40;e.KeyCode&#41;
[/QUOTE]

and remember to add a closing } after the switch block

hope that helps Joe

tkgafs

tkgafs
2004-09-17, 01:03 AM
Quote[/b] (colin @ Sep. 16 2004,21:08)]I&#39;m looking into adding a screen saver of sorts for this plugin, unless someone has done it or is doing it?

Colin.
Colin,

if you add screensaver functionality to the plugin how can we all reconcile the various changes to the plugin

is there diff &amp; patch like utilities ??

is the original author still about should we send all our changes to him to be amalgamated into his code ?

any thoughts

tkgafs

colin
2004-09-17, 04:04 AM
Well there are several ways this can work:

1. Patches are sent to the author of the plugin to integrate
2. We look to use something like sourceforge to maintain open src&#39;ed plugins
3. You fork off your own version of the plugin.
4. We organise amongst ourselves who applies their changes first.

cvs is still the most widely used src control application and as part of that it has utilties for creating diffs and applying patches.

Cheers,
Colin.

joecru
2004-09-17, 12:54 PM
Thanks tkgafs,

I will try this code out on my MVPs ASAP.


Regards
Joe

Tobias
2004-09-17, 06:21 PM
Good work tkgafs&#33;

If you dont mind I will use that code in my upcoming Album Player plug-in, maybe with different keys though since I have thought of other functions for the color keys http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif

Open source plugins is good, but I actually like the fact that GB-PVR is not open source...

I contacted Bryan (who has done the Jukebox plugin) and asked him for permission to use his code before I started to develop my plugin (and also got it, thanx as lot). Maybe you should contact him also tkgafs, and ask if he is interested in putting your code in his next version of the plugin?

Maybe as the number of developers grow, we can maintain a site and open source community for &quot;standard plugins&quot; to GB-PVR. But for now I think that what we got is more than enough.

joecru
2004-09-17, 08:56 PM
Hi tkgafs,

What do you mean by ,

encase the large switch block with the following code
[QUOTE]

Regards
Joe

tkgafs
2004-09-17, 09:15 PM
joe

in Bryans original code there is a section


switch (e.KeyCode)
{
then lots of case Keys.xxx statements

which will eventually end as follows

default:
handled = false;
break;
}


what you need to do is take my new code and add it before the switch statement

as follows

}
else
{
switch (e.KeyCode)
{
then all the case stuff down to
default:
handled = false;
break;
}
then add a closing
}

to match the one from the else above

if your still not to sure PM me your email address and I&#39;ll send you an edited copy of the code

Tkgafs

tkgafs
2004-09-17, 09:21 PM
Quote[/b] (Tobias @ Sep. 17 2004,18:21)]Good work tkgafs&#33;

If you dont mind I will use that code in my upcoming Album Player plug-in, maybe with different keys though since I have thought of other functions for the color keys http://gbpvr.com/iB_html/non-cgi/emoticons/smile.gif


no problem


Quote[/b] ]
I contacted Bryan (who has done the Jukebox plugin) and asked him for permission to use his code before I started to develop my plugin (and also got it, thanx as lot). Maybe you should contact him also tkgafs, and ask if he is interested in putting your code in his next version of the plugin?


I had already emailed Bryan asking what he wanted to do with my little bits of code but as of yet he hasn&#39;t replied

I have one tiny little change more I want to do to the plugin which is to add a default image if the folder doesn&#39;t contain a folder.jpg file

its only a couple of lines so I&#39;ll do it later tonight

Tkgafs

no problem

joecru
2004-09-17, 09:46 PM
Tkgafs,

I sent you a PM hope you received it ok.

Regards
Joe

joecru
2004-09-18, 10:53 AM
Tkgafs,

I have found where to place the 2nd code list, but when I run the compile program ,I am not getting the jukebox.dll file being created. The GBPVRPublic.dll is in the SharpDev dir but not Jukebox.dll. I followed Colins instructions but still no joy.What am I doing wrong?

The Project Options are set to (Debug) (Library) output is C:&#92;My Doc&#92;SharpDEv&#92;Jukebox and the same for Release.

Reference goes to the GBPVRPublic.dll in the C:&#92;programs&#92;denz&#92;GBPVR&#92;Plugins

The program RUNs ok in the SharpDEv

Regards
Joe

tkgafs
2004-09-18, 04:43 PM
Joe,

Sorry I only know what colin has explained about sharp develop so I dont know what you problem would be.

I got your PM but was hanging off sending the code until I had added another little bit of functionality, which is turning out to be much harder than I thought

tkgafs

sub
2004-09-20, 06:55 PM
I&#39;ve just uploaded tkgafs&#39; updates to the plugins page for anyone that wants it.

tkgafs
2004-10-19, 09:35 AM
there is a new version of the jukebox plugin available on the downloads page

this version has a couple of minor tweaks

corrects error which prevented it running correctly when using the scan skin

suppresses the track time slider when running on an MVP

improves the randomness of the random track selection by using a better seed for the random function

enjoy

tkgafs