PDA

View Full Version : Jukebox


cbk1994
04-11-2007, 03:36 AM
This is the Jukebox I made, many have requested the script, so I decided to release it to the public. Very simple, very easy to modify. If you use it, please if anyone asks give them the script. If you modify it (besides adding music), you can just give them the link to this, rather than the modified version.

Could probably be modded to play internet radio stations.


//#CLIENTSIDE
function onCreated()
{
showJukebox();
}
function onKeyPressed( code, key )
{
if ( key == "r" )
{
setTimer( 0.05 );
Jukebox_Window.visible = Jukebox_Window.visible - 1;
GraalControl.makeFirstResponder( true );
}
}
function onWeaponFired()
{
say2( "Press 'r' to toggle jukebox!" );
}
function showJukebox()
{
playing = this.playing;
Jukebox_Window.destroy();
new GuiWindowCtrl( "Jukebox_Window" )
{
profile = "GuiBlueWindowProfile";
width = 280;
height = 120;
x = screenwidth - width;
y = screenheight - height;
canClose = canMinimize = true;
canMaximize = canResize = false;
visible = false;
text = "Jukebox for" SPC servername;
useownprofile = true;
profile.transparency = .9;
new GuiMLTextCtrl( "Jukebox_Text" )
{
profile = "GuiBlueTextProfile";
x = 10;
y = 30;
width = 270;
height = 20;
useownprofile = true;
profile.align = "center";
text = "<center>Now playing:" SPC playing;
}
new GuiPopUpMenuCtrl( "Jukebox_List" )
{
profile = "GuiBluePopUpMenuProfile";
width = 260;
height = 20;
x = 10;
y = 50;
textprofile = "GuiBlueTextListProfile";
scrollprofile = "GuiBlueScrollProfile";
clearRows();
temp.music = {
{ "SONG_NAME", "SONG_URL" },
{ "SONG2_NAME", "SONG2_URL" } ;
for ( temp.i = 0; temp.i < temp.music.size(); temp.i ++ )
{
with( addRow( 0, temp.music[temp.i][0] ) )
{
this.var = temp.music[temp.i][1];
}
}
setSelectedRow( 0 );
sort();
}
new GuiButtonCtrl( "Jukebox_Stop" )
{
profile = "GuiBlueButtonProfile";
width = 75;
height = 30;
x = Jukebox_Window.width / 2 - ( width / 2 );
y = Jukebox_Window.height - 40;
text = "Stop Music";
}
}
stopmidi();
this.playing = "[None]";
Jukebox_Text = "Now playing: [None]";
}
function onTimeOut()
{
this.time += .05;;
setTimer( 0.05 );
}
function Jukebox_Stop.onAction()
{
stopmidi();
this.playing = "[None]";
Jukebox_Text = "Now playing: [None]";
}
function Jukebox_List.onSelect()
{
if ( this.time > 0 )
{
this.playing = params[1];
Jukebox_Text.text = "Now playing:" SPC params[1];
play( Jukebox_List.rows[params[2]].var );
}
}
function onPlay( title, song )
{
this.playing = title;
Jukebox_Text.text = "Now playing:" SPC title;
play( song );
}


Please leave feedback, my first released script.

Rapidwolve
04-11-2007, 03:38 AM
Screenies please?

cbk1994
04-11-2007, 04:04 AM
Sure.

Novo
04-11-2007, 07:43 AM
Jukebox_Window.visible = Jukebox_Window.visible - 1;


Should be one of the following:


Jukebox_Window.visible = !Jukebox_Window.visible;
Jukebox_Window.visible = 1 - Jukebox_Window.visible;
Jukebox_Window.visible = (Jukebox_Window.visible + 1)%2;
Jukebox_Window.visible = (Jukebox_Window.visible == true ? false : true );


The timer has no purpose: It seems like it is an overkill.


if ( this.time > 0 )

could be

if ( this.playing != "[None]" )

cbk1994
04-12-2007, 01:51 AM
Thanks for saying 'Nice code' or 'thanks!'. There's nothing wrong with the visible, the timer use to do something else which I removed for public release.

pez307
08-24-2009, 04:59 PM
Nice, but i get errors.



Script compiler output for Player/Jukebox:
error: unexpected token: ; at line 59: { "SONG2_NAME", "SONG2_URL" } ;
Weapon/GUI-script Player/Jukebox added/updated by pez307
Script: Function Jukebox_Window.destroy not found at line 22 in script of Player/Jukebox
Script: Function addcontrol not found at line 36 in script of Player/Jukebox
Script: Function setSelectedRow not found at line 67 in script of Player/Jukebox
Script: Function sort not found at line 68 in script of Player/Jukebox
Script: Function addcontrol not found at line 47 in script of Player/Jukebox
Script: Function addcontrol not found at line 70 in script of Player/Jukebox
Script: Function addcontrol not found at line 23 in script of Player/Jukebox
Script: Function stopmidi not found at line 80 in script of Player/Jukebox

Help please? :P

Chompy
08-24-2009, 05:09 PM
Nice, but i get errors.



Script compiler output for Player/Jukebox:
error: unexpected token: ; at line 59: { "SONG2_NAME", "SONG2_URL" } ;
Weapon/GUI-script Player/Jukebox added/updated by pez307
Script: Function Jukebox_Window.destroy not found at line 22 in script of Player/Jukebox
Script: Function addcontrol not found at line 36 in script of Player/Jukebox
Script: Function setSelectedRow not found at line 67 in script of Player/Jukebox
Script: Function sort not found at line 68 in script of Player/Jukebox
Script: Function addcontrol not found at line 47 in script of Player/Jukebox
Script: Function addcontrol not found at line 70 in script of Player/Jukebox
Script: Function addcontrol not found at line 23 in script of Player/Jukebox
Script: Function stopmidi not found at line 80 in script of Player/Jukebox

Help please? :P


The temp.music array is missing an ending bracet (:
Put a '}' instead of the space between } and ; at line 59

salesman
08-24-2009, 07:15 PM
do you have //#CLIENTSIDE at the top?

pez307
08-25-2009, 02:09 PM
Nice jukebox Chris ;)

Mark Sir Link
08-25-2009, 04:29 PM
thanks for saying 'nice code' or 'thanks!'. There's nothing wrong with the visible, the timer use to do something else which i removed for public release.

lol