PDA

View Full Version : playing music with select.



riptide
04-17-2007, 06:08 PM
okay I really didn't want to have to ask about this script but. I'm not getting any where with it.


here I wanted a function to store the selected options values and names
the values go in var userChoose and names go in var showPlaying.

for every selection made more values an names are added to an array
userList holds the vaues and seeList holds the names.

seelist is displyed on a textarea


/*display songs*/

function nowloading(){var playing=document.misterioRadio.Mchooser.selectedIndex;
var userChoose=document.misterioRadio.Mchooser.options[playing].value;
var showPlaying=document.misterioRadio.Mchooser.options.name;
var playCount=0;
var clist=0;
playCount++;
clist++;
var userList= new Array();
var seeList=new Array();
seeList[clist]=showPlaying;
document.RiptideControls.MisterioScreen.value=seeList.join("/n");
var playReady=userList[playCount];
RtoK=window.event}



then there is a function to get the right classid for whatever player person has.


function nowplaying(){function findCoad(){
try{document.write('clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6 ');
Play()}catch(e)
try{document.write('clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B');
Play()}catch(e)
try{document.write('clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA');
DoPlay()}catch(alert('you need a plugin try realy player'))}

then a function to limit each songs playing time to 6 minutes . and go to the next song


function seek(){
var songNum=0;
var playTime=360000;

if (songNum<(playReady.length-1)){songNum++}else{songNum=0}}
document.playReady=playReady[songNum];
setTimeout('seek()',playTime);
try {DoPlay()}catch(e)try{Play()};

function to make a song repeat

function rep(){
var seed=null;
var chR=document.MisterioScreen.repet.style.border;
if(chR="inset"){seed=songNum=0}
else if(chR="outset") {seed=Stop();DoStop()};
if(chR="outset"){chR.Onclick=ChR="inset"}else if (chR="inset"){chR.Onclick=ChR="outset"}}
function to shuffle


function confuse(){ if (RiptideControls.MisterioScreen.shuf.value=true)
nowPlaying(playReady{misingo(nowplaying.length-1)]}
function misingo(n){sh=Math.floor(Math.random()*(n+1));return sh;}

then a few other functions.


function restart(){getElementById('MisterioScreen').onReset=playReady.length=0}
function Jsec(){try{Pause()}catch(e)try{DoPause()}}
function stopper(){try {Stop(); DoStop()}catch("cant stop");
function rewind() { if (reer==true){songNum-1}}

here is the HTML (the songs are just for show here.)


<object data="" autostart="false" "true">
<embed src="" autostart="faluse" enablejavascript="true"></embed>
</object>



<div id="RiptideControls">
<input type="button" onclick="nowLoading()" value="add"/>
<h1 id="Mtitle"> play list</h1>
<p>to fix mistakes you have to clear the whole playlist</p>
<form id="MisterioScreen">
<textarea cols="50" rows="4" name="Mscreen" readonly="readonly"></textarea>


<input name="reset" value="reset" onclick="restart()"type="reset"/>
<input type="button" value="shuffle" onclick="confuse()"/>
<input type="button" value="play" onClick="nowplaying()"/>
<input type="button" value="stop" onClick="stoper()"/>
<input type="button" value="rewind" id="reer" onClick="rewind()"/>
</form>
</div>

<form id="misterioRadio">
<select name="Mchooser" size="4" >
<option value="choose a song" selected="selected">
<option value="Blue Oyster Cult - Don't Fear The Reaper.mp3 " > nunberone </option>
<option value="Red Hot Chilli Peppers - Dani California.mp3" > second </option>
<option value="Rob Zombie - Educated Horses 02 american witch.mp3" > third </option>
</select></form>

riptide
04-17-2007, 07:35 PM
too complex or is it (var playCount=0;
var clist=0;
playCount++;
clist++; )
some of the code is stupid.

I don't think clist need to ++

riptide
04-18-2007, 06:41 PM
is this any better?




function nowloading(){var playing=document.getElementsById(Mchooser).selectedIndex;
var userChoose=document.getElementsById(Mchooser).options[playing].value;
var showPlaying=document.getElementsById(Mchooser).options.name;



for (var i=0;i<userChoose.length;i++) {
if (userChoose[i].selected) {var userList= new Array(showPlaying[i])
);

for (var i=0;i<showPlaying.length;i++) {
if (showPlaying[i].selected) {
words.push(showPlaying[i].text);
document.RiptideControls.MisterioScreen.value=seeList.join("/n");

var playCount=0;
playCount++;
var playReady=userList[playCount];
e=window.event}