[Tutor] Python in HTML

Orri Ganel singingxduck at gmail.com
Sun May 22 02:07:22 CEST 2005


Alan G wrote:

>OK, so what happened?
>Did you start just making the copy and playing the songs from the
>copy?
>Did that work OK?
>
>Does the random number generation work - I assume you tested that by
>just writing out the sequence of numbers first?
>
>And finally when you use the random numbvers to select songs does it
>pick the songs as you expect?
>
>I still don't know what we are looking for as a problem?
>
>But writing code in Javaript is like any other language, except
>the debugging environment of poorer! You start doing the easy things
>and build on features one by one, fixing as you go. As soon as you
>get a feature working put it in a function. It keeps the working code
>and experimental stuff separate!
>
>Alan G.
>
Well, like I said, the darkplayer is on an online journal, which means 
that the only output possible is modifying the option strings of songs 
as they are played or something similar.  I do know that the random 
number generator works, and the songs played always match the option 
selected.  However, this was before adding the bit about copying the 
songs and playing from the copy.  The last fully functional version 
(without the 'play all songs once' feature) is as follows:

<object id=darkplayer 
codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#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="False">
</object>
<form name=form>
 <p style="text-align: center">
 <select style="FONT-SIZE: 8pt; BACKGROUND:#FFFFFF; WIDTH: 302; COLOR: 
#00000; font-face: verdana;" name=playlist size=1>
 <option value="0">removed</option>
 
 
 </select><br>
 <input TYPE="BUTTON" NAME="darkplay" VALUE="play" 
OnClick="play(document.forms['form'].playlist);playstate=0;">
 <input TYPE="BUTTON" NAME="darkpause" VALUE="pause" 
OnClick="document.darkplayer.pause(); playstate=1;">

 <input TYPE="BUTTON" NAME="darkstop" VALUE="stop" 
OnClick="document.darkplayer.stop(); playstate=2;">
 <input TYPE="BUTTON" NAME="random" VALUE="random" 
OnClick="randsong();play(document.forms['form'].playlist);">
</p></form>


<script language="JavaScript">
<!--
var playstate = 0;
shuffle = 1;  // set to 0 to always play first song in list
                  // set to 1 to randomly choose the first song to play
                  // www.xanga.com/singing_duck
                  // unlimited songs, just copy and paste the song line 
and change the number
songs=new Array();
songs[0]="removed"

function randsong() {
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};
function rand(number) {
        return Math.ceil(rnd()*number);
};
var randsg = rand(songs.length);
document.darkplayer.FileName = songs[randsg];
document.darkplayer.scr = songs[randsg];
document.forms['form'].playlist.options[randsg].selected = true;
};
if (shuffle == 1) {
randsong();
}
function play(list) {
 if (playstate == 1 && songs[list.options[list.selectedIndex].value] == 
document.darkplayer.FileName) {
  document.darkplayer.Play();
} else {
var snum = list.options[list.selectedIndex].value
document.darkplayer.FileName = songs[snum];
document.darkplayer.scr = songs[snum];
}
playstate = 1;
};
//-->
  </script>

-- 
Email: singingxduck AT gmail DOT com
AIM: singingxduck
Programming Python for the fun of it.



More information about the Tutor mailing list