Help - Search - Members - Calendar
Full Version: Help with JukeBox Script
Forums > Resource Center > Support Center > Blogger Support > Blogger Resolved Topics
voltigeur
Hey guys, I was wondering if someone could help me figure out the problem with my (i ripped part of it from createblog.com.. so it isn't quite mine) script. ermm.gif

You see, the main issue I'm facing right now is that the player simply wouldn't shuffle and play the next song on the list (as it should). It would just constantly repeat the same song that plays right at the start whenever the page loads up.

I would really appreciate it if someone could help me out with this!

edit: I removed the forms section cause I don't want a dropdown list to show up on my blog.

Here's the script:


===========================================================

CODE
<!-- begin code provided by createblog.com -->
<object id="darkplayer"

codeBase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.c

ab#Version=5,1,52,701" type="application/x-oleobject" height="0"

standby="Loading Microsoft Windows Media Player components..." width="0"

classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95">
<param NAME VALUE>
<param NAME="ShowControls" VALUE="0">
<param NAME="ShowStatusBar" VALUE="0">
<param NAME="ShowDisplay" VALUE="0">
<param NAME="DefaultFrame" VALUE="Slide">
<param NAME="Autostart" VALUE="1">
<param NAME="Loop" VALUE="True">
</object>

<script Language="JavaScript">
<!--
var playstate = 1;

var shuffle = true;  // false = shuffle off, true = shuffle on

var autoStart = true;   // false = autoStart off, true = autoStart on

songs=new Array();

// Add song URLs here
songs[0]="songurl1";
songs[1]="songurl2";
songs[2]="songurl3";

if (shuffle == 1) {
var randsg = Math.floor(Math.random()*songs.length);
document.darkplayer.FileName = songs[randsg];
document.darkplayer.src = songs[randsg];
}
function play(list) {
if (playstate == 2) {
document.darkplayer.Play();
} else {
var snum = list.options[list.selectedIndex].value
document.darkplayer.FileName = songs[snum];
document.darkplayer.src = songs[snum];
}
playstate = 1;
}
//-->
</script>
<!-- end code provided by createblog.com -->
moorepocket
did you copy the code as is?
If it doesn't work, then i guess there not much you can do.
voltigeur
Well yeah, I did.. except the fact that I removed the dropdown list.

Is that what's causing the problem? Cause I don't really want the dropdown list to show up on my blog.

What I want is just for the songs to play randomly, one after another when people visit my blog. Heh.
Kathleen
Can I see your Blogger?
voltigeur
edit: i'll pm it to you instead, Kathleen
voltigeur
Ok, the problem still ain't fixed yet. I've uploaded the entire script into my blog. The code's definitely working (I tried the code out on my friend's blog, who's layout is a simple 1 page skin). The main problem I'm facing right now is getting the buttons to work and the script to actually recognise that the 'form' is within an ELEMENT. The script also fails to play the next random song on the list too!

Is there anyone out there who can help me out with this? Perhaps all I need to do is to extend the linking codes.. but I have no idea how to. Looking forward to some positive replies! biggrin.gif

note: I've removed additional codes in other to avoid confusion.


CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<meta http-equiv="imagetoolbar" content="no">
<meta content="progid:DXImageTransform.Microsoft.Pixelate(Duration=3)" http-equiv="Page-Enter">
<meta content="progid:DXImageTransform.Microsoft.Pixelate(Duration=3)" http-equiv="Page-Exit">




<div style="position:absolute; top:35px; left:75px" >
<img src="http://img.photobucket.com/albums/v633/whats-with-me/blogskininverted.jpg">
</div>

<title>&nbsp;a distance that was felt, a distance i couldn't run.</title>
<style type="text/css">

a:link      {text-decoration: none; color: #FFFFFF; }
a:visited    {text-decoration: none; color: #FFFFFF; }
a:active     {text-decoration: none; color: #FFFFFF; }
a:hover    {text-decoration: none; color: #5effe3; cursor: crosshair;;

height:0; filter:blur(add="1",direction="90",strength="9");}


body         
{ background-attachment: fixed;
background:#256b9c;
     font-family: arial;
     color:#ffffff;
     line-height:130%;  
     text-align:left;
     margin: 0px;
     font-size: 12pt;
          cursor:crosshair;
}

div {
         filter:chroma(color=#FF9966);
    scrollbar-arrow-color: #ffffff;
    scrollbar-face-color: #FF9966; /* transparent */
    scrollbar-3dlight-color: #F9966;
    scrollbar-darkshadow-color: #ffffff;
    scrollbar-highlight-color: #FF9966; /* transparent */s
    scrollbar-shadow-color: #FF9966; /* transparent *mp/
    scrollbar-track-color: #FF9966; /* transparent */    
}





.blog{
color: #ffffff;
font-size: 12px;
font-family: franklin gothic medium;
font-weight: normal;
cursor:crosshair;
overflow:auto;
}

.blogheader{
color: #ffffff;
font-size: 13px;
font-family: century gothic;
font-weight: bold;
margin:0px;
border-style: solid;
border-color: #ffffff;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 2px;
border-left-width: 0px;
text-align: left;
cellpadding:2px;
letter-spacing: 2pt;
cursor:crosshair;
}

.bottombar{
color: #ffffff;
font-size: 10px;
font-weight: bold;
font-family: arial;
cursor:crosshair;
}


.author{
color: #ffffff;
font-size: 11px;
font-weight: bold;
font-family: "lucida sans unicode";
cursor:crosshair;
letter-spacing: 2pt;
cursor:crosshair;
}

.scripts{
color: #ffffff;
font-size: 10px;
font-family: arial;
font-weight: bold;
cursor:crosshair;
}

.others{
color: #ffffff;
font-size: 13px;
font-family: arial;
font-weight: solid;
cursor:crosshair;
letter-spacing: 0pt;
cellpadding:2px;
cursor:crosshair;
}

#navbar-iframe{
height:0px;
visibility:hidden;
display:none
}

</style>
</style>
<!-- --><style type="text/css">@import url

(http://www.blogger.com/css/navbar/classic.css);
div.b-mobile {display:none;}
</style>

<!-- --><style type="text/css">@import url(http://www2.blogger.com/css/navbar/classic.css);
div.b-mobile {display:none;}
</style>

</head><body>      <iframe src="http://www2.blogger.com/navbar.g?targetBlogID=76801741937178941&amp;blogName=the+lonely+journey&amp;publishMode=PUBLISH_MODE_BLOGSPOT&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;homepageUrl=http%3A%2F%2Fthelonelyjourney.blogspot.com%2Findex.html&amp;searchRoot=http%3A%2F%2Fthelonelyjourney.blogspot.com%2Fsearch" height="30px" width="100%" marginwidth="0" marginheight="0" scrolling="no" id="navbar-iframe" frameborder="0"></iframe> <div id="space-for-ie"></div>    <iframe src="http://www.blogger.com/navbar.g?blogID=22700950"

height="30px" width="100%" marginwidth="0" marginheight="0" scrolling="no"

id="navbar-iframe" frameborder="0"></iframe> <div id="space-for-ie"></div>
</tr>
</table>
</body>
</html>

<div id="main" style="position: absolute; z-index:2; overflow:auto; left:390; top:105; width: 510; height:350; background-color: transparent; border:none">
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the neverending road of loneliness
<br>
<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;....i am alone.
</div>

<!--sidebar-->
<div id="bottombar" style="position: absolute; z-index: 5; overflow: auto; left:406.5; top:490; width: 470; height: 25; background-color:transparent;

border:none">
<div class="bottombar">
  
   [<font color='#53adc5'">&dagger;</font>]<span style="cursor: crosshair;"

onClick="document.getElementById('main').innerHTML=document.getElementById

('blog').innerHTML" onMouseOver="this.style.color='#5effe3'"

onMouseOut="this.style.color='#ffffff'">Reflections</span>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<font

color='#53adc5'">&dagger;</font>]<span style="cursor: crosshair;"

onClick="document.getElementById('main').innerHTML=document.getElementById

('tagboard').innerHTML" onMouseOver="this.style.color='#5effe3'"

onMouseOut="this.style.color='#ffffff'">Tagboard</span>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<font

color='#53adc5'">&dagger;</font>]<span style="cursor: crosshair;"

onClick="document.getElementById('main').innerHTML=document.getElementById

('archive').innerHTML" onMouseOver="this.style.color='#5effe3'"

onMouseOut="this.style.color='#ffffff'">Memories</span>
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<font

color='#53adc5'">&dagger;</font>]<span style="cursor: crosshair;"

onClick="document.getElementById('main').innerHTML=document.getElementById

('links').innerHTML" onMouseOver="this.style.color='#5effe3'"

onMouseOut="this.style.color='#ffffff'">Crossroads</span>  

</object>
</font>
</div></div></tr>
</table>



<div id="tagboard" style="position:absolute; z-index:1; visibility:hidden; overflow:hidden; left:360; top:105; width:540; height:350; background-color:transparent; border:none">[/b]


<!-- start code provided by createblog.com -->
<object id="Player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="0" height="0">
<param value="invisible" name="uiMode"/>
<param value="False" name="Autostart"/>
</object>

<form id="form" style="position:absolute; left:170; top:255;">

<select id="playlist" size="1">

<!-- Add song info that appears in drop down list here -->
<option value="0"/>Switchfoot - Dare You To Move
<option value="1"/>Switchfoot - The Shadow Proves The Sunshine
<option value="2"/>David Foster - Love Theme from St. Elmo's Fire

</select>

<br/>
<button id="BackButton" onclick="Back(forms['form'].playlist);"> << </button>
<button id="PlayPauseButton" onclick="PlayPause(forms['form'].playlist);"><font color="green"><strong>  Play  </strong></font></button>
<button id="NextButton" onclick="Next(forms['form'].playlist);"> >> </button>
<button id="StopButton" onclick="Stop();"><font color="maroon"><strong>Stop<strong></font></button>
<b><font color="white" size="3">Shuffle</font></b><input id="ShuffleSwitch" checked value="ON" onclick="ToggleShuffle(this);" type="checkbox"/>

</form>    



<comment id="PlayHTML"><font color="Green"><strong>  Play  <strong></font></comment>
<comment id="ShuffleOnHTML"><input id="ShuffleSwitch" checked onclick="ToggleShuffle(this);" type="checkbox"/></comment>
<comment id="ShuffleOffHTML"><input id="ShuffleSwitch" unchecked onclick="ToggleShuffle(this);" type="checkbox"/></comment>


<script id="Main" language="JavaScript">

    var songs = new Array();

    //*******************************//
    //****** CHANGEABLE STUFF *******//
    //*******************************//
    
    var shuffle = true;  // false = shuffle off, true = shuffle on

    var autoStart = true;   // false = autoStart off, true = autoStart on
    
    var numberTracks = false;  // true = place track number in front of list items, false = no track numbers
    
    // Add song URLs here (make sure it matches up with the order you have for song info, and urls need quotes):
    songs[0]="http://www.fileden.com/files/2007/1/1/579683/Switchfoot%20-%20Dare%20You%20to%20Move.mp3";
    songs[1]="http://www.fileden.com/files/2007/1/1/579683/Switchfoot%20-%20The%20Shadow%20Proves%20The%20Sunshine.mp3";
    songs[2]="http://www.fileden.com/files/2007/1/1/579683/David%20Foster%20-%20Love%20Theme%20from%20%27%27St.%20Elmo%27s%20Fire%27%27.mp3";

    
    //*******************************//
    //*******************************//

// Initializations //
with (document){
    var length = forms['form'].playlist.length;

    if(numberTracks){
  for (var i = 0; i < length; i++){
      forms['form'].playlist.options[i].innerHTML = (i+1) + " - " + forms['form'].playlist.options[i].innerHTML;
  }
    }
    
    if (shuffle) {
  var randsg = Math.floor(Math.random()*songs.length);
  Player.url = songs[randsg];
  forms['form'].playlist.options[randsg].selected = true;
  forms['form'].ShuffleSwitch.outerHTML = ShuffleOnHTML.innerHTML;
    }

    else {
  forms['form'].ShuffleSwitch.outerHTML = ShuffleOffHTML.innerHTML;
  Player.url = songs[0];
    }

    if(autoStart){
  var snum = forms['form'].playlist.selectedIndex;
  if(Player.url != songs[snum]){
      Player.url = songs[snum];
  }
  Player.controls.Play();
    }
}

// Functions //
// Description: "PlayPause" will toggle playing and pausing if the same song is still selected,
//              otherwise it will load the newly selected song
function PlayPause(list) {
    var snum = list.selectedIndex;
    
    if((Player.url == songs[snum] && Player.url != "") && Player.playState != 1){
  if(Player.playState == 3){
      Player.controls.Pause();
  }
  
  else {
      Player.controls.Play();
  }
    }

    else {
  Player.url = songs[snum];
  Player.controls.Play();
    }
}

// Description: "Next" will move to the next music file if shuffle is off
//              otherwise it will load a random song. Calls PlayPause to start music.
function Next(list) {
    var snum = list.selectedIndex;
    if (!shuffle) {
  if (snum == list.length-1) {
      snum = -1;
  }
  snum++;
    }
    
    else {
  var temp;
  do{
      temp = Math.floor(Math.random()*songs.length);
  } while(temp == snum);
  snum = temp;
    }
    
    list.options[snum].selected = true;
    PlayPause(list);
}

// Description: "Back" does the same thing as "Next" but moves backwads
//              through the list. If shuffle is on then picks a random song.
function Back(list) {
    var snum = list.selectedIndex;
    if (!shuffle) {
  if (snum == 0){
      snum = list.length;
  }
  snum--;
    }
    
    else {
  var temp;
  do{
      temp = Math.floor(Math.random()*songs.length);
  } while(temp == snum);
  snum = temp;
    }
    
    list.options[snum].selected = true;
    PlayPause(list);
}

// Description: Self explanitory.
function Stop(){
    Player.controls.Stop();
}

// Description: Makes the shuffle flag the same as the status of the CheckBox
//    The status of the checkbox (true/false) indicates if the box is checked
function ToggleShuffle(CheckBox) {
    shuffle = CheckBox.status;
}

</script>

<script id="StateChangeHandler" for="Player" language="JavaScript" event="playStateChange(NewState)">

// Description: This is an interupt handler used to handle instances when the
//              state of the player changes to play or stop for example.

//STATE.innerText = NewState;

switch(NewState){
    case 8:  // Handles player after it just finishes playing through a song
  var num = document.forms['form'].playlist.selectedIndex;
    
  if (!shuffle){
      if(num == document.forms['form'].playlist.length-1){
    num = -1;
      }
  
      num++;
  }
  else {
      var temp;
      do{
    temp = Math.floor(Math.random()*songs.length);
      } while(temp == num);
      num = temp;
  }
    
  document.forms['form'].playlist.options[num].selected = true;
    
  PreviousState = NewState;
  break;

    case 1: // Handles player after it stops
  if(PreviousState == 8){
      var num = document.forms['form'].playlist.selectedIndex;
      Player.settings.autoStart = true;
      Player.url = songs[num];
      PreviousState = NewState;
  }
  
  else if (PreviousState != 3 && PreviousState != 2){
      Player.controls.Play();
      Player.settings.autoStart = false;
  }
  
  else{
      forms['form'].PlayPauseButton.innerHTML = PlayHTML.innerHTML;
  }
  break;

    case 3: // Handles player after it starts to play
  PreviousState = NewState;
  forms['form'].PlayPauseButton.innerHTML = "Pause";
  shuffle = document.forms['form'].ShuffleSwitch.status;
  break;

    case 2: // Handles player after being paused
  PreviousState = NewState;
  forms['form'].PlayPauseButton.innerHTML = PlayHTML.innerHTML;
  break;

    default:
}

</script>
<!-- end code provided by createblog.com -->

</div>
moorepocket
try this for juke box instead.

Your codes work but you have to press play. Check out my blogger to see what i mean.
voltigeur
check out my blogger: http://thelonelyjourney.blogspot.com/

@moorepocket: i can't quite figure out how to use the codes that you've provided. sad.gif

note: problem still ain't solved yet!
moorepocket
i fibbed with your code a little.

CODE
<object id="Player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="0" height="0">
<param value="invisible" name="uiMode"/>
<param value="False" name="Autostart"/>
</object>

<form id="form">

<select id="playlist">

<!-- Add song info that appears in drop down list here -->
<option value="0"/>Dare You To Move
<option value="1"/>The Shadow Proves The Sunshine
<option value="2"/>Love Theme from St. Elmo's Fire

</select>

<br/>
<button id="BackButton" onclick="Back(forms['form'].playlist);"> << </button>
<button id="PlayPauseButton" onclick="PlayPause(forms['form'].playlist);"><strong> Play </strong></button>
<button id="NextButton" onclick="Next(forms['form'].playlist);"> >> </button>
<button id="StopButton" onclick="Stop();"><strong>Stop<strong></button>
<b><font color="white">Shuffle</font></b><input id="ShuffleSwitch" checked value="ON" onclick="ToggleShuffle(this);" type="checkbox"/>

</form>



<comment id="PlayHTML"><strong> Play <strong></comment>
<comment id="ShuffleOnHTML"><input id="ShuffleSwitch" checked onclick="ToggleShuffle(this);" type="checkbox"/></comment>
<comment id="ShuffleOffHTML"><input id="ShuffleSwitch" unchecked onclick="ToggleShuffle(this);" type="checkbox"/></comment>


<script id="Main" language="JavaScript">

var songs = new Array();

//*******************************//
//****** CHANGEABLE STUFF *******//
//*******************************//

var shuffle = true; // false = shuffle off, true = shuffle on

var autoStart = true; // false = autoStart off, true = autoStart on

var numberTracks = false; // true = place track number in front of list items, false = no track numbers

// Add song URLs here (make sure it matches up with the order you have for song info, and urls need quotes):
songs[0]="http://www.fileden.com/files/2007/1/1/579683/Switchfoot%20-%20Dare%20You%20to%20Move.mp3";
songs[1]="http://www.fileden.com/files/2007/1/1/579683/Switchfoot%20-%20The%20Shadow%20Proves%20The%20Sunshine.mp3";
songs[2]="http://www.fileden.com/files/2007/1/1/579683/David%20Foster%20-%20Love%20Theme%20from%20%27%27St.%20Elmo%27s%20Fire%27%27.mp3";


//*******************************//
//*******************************//

// Initializations //
with (document){
var length = forms['form'].playlist.length;

if(numberTracks){
for (var i = 0; i < length; i++){
forms['form'].playlist.options[i].innerHTML = (i+1) + " - " + forms['form'].playlist.options[i].innerHTML;
}
}

if (shuffle) {
var randsg = Math.floor(Math.random()*songs.length);
Player.url = songs[randsg];
forms['form'].playlist.options[randsg].selected = true;
forms['form'].ShuffleSwitch.outerHTML = ShuffleOnHTML.innerHTML;
}

else {
forms['form'].ShuffleSwitch.outerHTML = ShuffleOffHTML.innerHTML;
Player.url = songs[0];
}

if(autoStart){
var snum = forms['form'].playlist.selectedIndex;
if(Player.url != songs[snum]){
Player.url = songs[snum];
}
Player.controls.Play();
}
}

// Functions //
// Description: "PlayPause" will toggle playing and pausing if the same song is still selected,
// otherwise it will load the newly selected song
function PlayPause(list) {
var snum = list.selectedIndex;

if((Player.url == songs[snum] && Player.url != "") && Player.playState != 1){
if(Player.playState == 3){
Player.controls.Pause();
}

else {
Player.controls.Play();
}
}

else {
Player.url = songs[snum];
Player.controls.Play();
}
}

// Description: "Next" will move to the next music file if shuffle is off
// otherwise it will load a random song. Calls PlayPause to start music.
function Next(list) {
var snum = list.selectedIndex;
if (!shuffle) {
if (snum == list.length-1) {
snum = -1;
}
snum++;
}

else {
var temp;
do{
temp = Math.floor(Math.random()*songs.length);
} while(temp == snum);
snum = temp;
}

list.options[snum].selected = true;
PlayPause(list);
}

// Description: "Back" does the same thing as "Next" but moves backwads
// through the list. If shuffle is on then picks a random song.
function Back(list) {
var snum = list.selectedIndex;
if (!shuffle) {
if (snum == 0){
snum = list.length;
}
snum--;
}

else {
var temp;
do{
temp = Math.floor(Math.random()*songs.length);
} while(temp == snum);
snum = temp;
}

list.options[snum].selected = true;
PlayPause(list);
}

// Description: Self explanitory.
function Stop(){
Player.controls.Stop();
}

// Description: Makes the shuffle flag the same as the status of the CheckBox
// The status of the checkbox (true/false) indicates if the box is checked
function ToggleShuffle(CheckBox) {
shuffle = CheckBox.status;
}

</script>

<script id="StateChangeHandler" for="Player" language="JavaScript" event="playStateChange(NewState)">

// Description: This is an interupt handler used to handle instances when the
// state of the player changes to play or stop for example.

//STATE.innerText = NewState;

switch(NewState){
case 8: // Handles player after it just finishes playing through a song
var num = document.forms['form'].playlist.selectedIndex;

if (!shuffle){
if(num == document.forms['form'].playlist.length-1){
num = -1;
}

num++;
}
else {
var temp;
do{
temp = Math.floor(Math.random()*songs.length);
} while(temp == num);
num = temp;
}

document.forms['form'].playlist.options[num].selected = true;

PreviousState = NewState;
break;

case 1: // Handles player after it stops
if(PreviousState == 8){
var num = document.forms['form'].playlist.selectedIndex;
Player.settings.autoStart = true;
Player.url = songs[num];
PreviousState = NewState;
}

else if (PreviousState != 3 && PreviousState != 2){
Player.controls.Play();
Player.settings.autoStart = false;
}

else{
forms['form'].PlayPauseButton.innerHTML = PlayHTML.innerHTML;
}
break;

case 3: // Handles player after it starts to play
PreviousState = NewState;
forms['form'].PlayPauseButton.innerHTML = "Pause";
shuffle = document.forms['form'].ShuffleSwitch.status;
break;

case 2: // Handles player after being paused
PreviousState = NewState;
forms['form'].PlayPauseButton.innerHTML = PlayHTML.innerHTML;
break;

default:
}

</script>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.