// ================================================= //
// The RealAudio Box v1.11 by Elton Kong (98/07/11). //
// (c)1997 Elton Kong. All Rights Reserved. //
// You can freely use or modify the script, as long //
// as this message is kept intact in the source. //
// //
// Contact me by: //
// mailto:cselton@polyu.edu.hk //
// http://www.comp.polyu.edu.hk/~cselton/ //
// ================================================= //
// Suppress JavaScript error messages
window.onerror=null;
// Relative path to song files
// Embedded player
// Object storing song names
var RA_Dir, RA_Player, RA_Song;
// Repeat mode indicator
// Random mode indicator
// Flag if a timer is running
// Timer id for monitor
var RA_Repeat, RA_Random;
var RA_TimerId;
// Set repeat mode
function RA_setRepeat() {RA_Repeat.checked=true;}
function RA_clearRepeat() {RA_Repeat.checked=false;}
// Set random mode
function RA_setRandom() {RA_Random.checked=true;}
function RA_clearRandom() {RA_Random.checked=false;}
// Set monitor
// -- Currently only monitors repeat mode
function RA_setMonitor() {
if (!RA_Player.CanStop()) {
if (RA_Repeat.checked) RA_play();
} else {
RA_TimerId=setTimeout("RA_setMonitor()", 1000);
}
}
function RA_clearMonitor() {
clearTimeout(RA_TimerId);
}
// Play song according to current mode
function RA_play() {
if (RA_Player.CanStop()) return;
if (RA_Random.checked) {
var idx=Math.floor(Math.random()*RA_Song.length);
RA_Song.options[idx].selected=true;
} else {
var idx=RA_Song.selectedIndex;
}
var src=RA_Dir+RA_Song.options[idx].value;
RA_Player.SetSource(src);
RA_Player.DoPlayPause();
RA_setMonitor();
}
// Pause/Resume current song
function RA_pause() {
if (RA_Player.CanStop()) RA_Player.DoPlayPause();
}
// Stop current song
function RA_stop() {
RA_clearMonitor();
if (RA_Player.CanStop()) RA_Player.DoStop();
}
// Initialise player
function RA_init() {
RA_Dir=";
RA_Player=document.embeds["RA_ebdPlayer"];
RA_Song=document.forms["RA_frmPanel"].selSong;
RA_Repeat=document.forms["RA_frmPanel"].ckbRepeat;
RA_Random=document.forms["RA_frmPanel"].ckbRandom;
// Play random song once at the start
RA_clearRepeat();
RA_setRandom();
RA_play();
RA_clearRandom();
}