Quote:
Originally Posted by Dblevins
I've tried this using an asx file. Again it works but now I have no way of chosing the file to be played.
I really don't mind how this is done as long as the end result is that viewers to the site can choose from a selection of playlists what they want to hear or see
Any ideas would be appreciated.
|
I believe you can choose the song with an asx file, it would be done by the media player however, and you can use js to control the media player..
If I remember correctly, all an .asx file is, is an XML file with the list of media files and some meta data associated with each media file. So the .asx file will be loaded to the media player as the playlist, controlling the songs will be controlling the playlist..
With the code you had before, the problem was that when you copied, you created multiple "id" attributes of the same name - like mentioned.
What you can do is create copies of the FORM SELECT Element:
Code:
<SELECT id=cancion onchange=document.all.music.filename=document.all.cancion.value; size=1 name=Music>
<OPTION selected>::::::::::::: Choose Your Song Here :::::::::::::</OPTION>
<OPTION value=http://url or path to your media>Artist - Song Title</OPTION>
<OPTION value=http://url or path to your media>Artist - Song Title</OPTION>
<OPTION value=http://url or path to your media>Artist - Song Title</OPTION>
</SELECT>
rename the id to what you want, and rename the reference to the id in your JS.
Code:
<SELECT id=cancion2 onchange=document.all.music.filename=document.all.cancion2.value; size=1 name=Music>
<OPTION selected>::::::::::::: Choose Your Song Here :::::::::::::</OPTION>
<OPTION value=http://url or path to your media>Artist - Song Title</OPTION>
<OPTION value=http://url or path to your media>Artist - Song Title</OPTION>
<OPTION value=http://url or path to your media>Artist - Song Title</OPTION>
</SELECT>
Notice "cancion2" is the new id for the second select box. "music" is still the id of the media player/plugin since there is only one copy. If you copy that, you have to rename the id also, and the references in the JS.
FWIW: The JS code you have looks a bit old. You may want to look into changing it to W3C DOM compatible code. The HTML is also invalid, since you need to surround attribute values with double quotes (").
eg: valid XHTML
Note all the tags are lower case and attribute values are in double quotes.
Code:
<select id="cancion2" onchange="document.all.music.filename=document.all.cancion2.value;" size="1" name="music">
<option selected>::::::::::::: Choose Your Song Here :::::::::::::</option>
<option value=http://url or path to your media>Artist - Song Title</option>
<option value=http://url or path to your media>Artist - Song Title</option>
<option value=http://url or path to your media>Artist - Song Title</option>
</select>
eg: W3C DOM compatible JS
Note: the document.getElementById('music') references the Element with ID of "music".
Code:
<select id="cancion2" onchange="document.getElementById('music').filename=document.getElementById('cancion2').options[document.getElementById('cancion2').options.selectedIndex].value;" size="1" name="music">
<option selected="selected">::::::::::::: Choose Your Song Here :::::::::::::</option>
<option value="http://url or path to your media">Artist - Song Title</option>
<option value="http://url or path to your media">Artist - Song Title</option>
<option value="http://url or path to your media">Artist - Song Title</option>
</select>
Explanation:
You have a media plugin with the ID "music", embedded in your HTML. Thus, you can reference it like another HTML Element via the DOM methods.
To reference an Element with a given id, DOM specifies:
Code:
document.getElementById();
You use this to retrieve the plugin Object, and then reference the attribute of the plugin called "filename" (which is the file to play).
Code:
document.getElementById('music').filename
You then make this equal to the selected Option value in the Select Element. Thus it changes the song being played.