?
Solved

Embed Src question

Posted on 2005-03-19
5
Medium Priority
?
518 Views
Last Modified: 2012-08-13
Why i can't change the src of the embed player to play another song...
How to do when i select a value on the dropdown menu to change the src of the embed player ?


   Music Player :
   <br />
    <select name="musiclist" onchange="javascript:MusicChange(this);">
     <optgroup label="WMA">
      <option value="WMA-1"> Unknown </option>
     </optgroup>
     <optgroup label="MP3">
      <option value="MP3-1"> The Reason </option>
     </optgroup>
     <optgroup label="MIDI">
      <option value="Midi-1.mid" selected> Midi-1 </option>
      <option value="Midi-2.mid"> Midi-2 </option>
      <option value="Midi-3.mid"> Midi-3 </option>
     </optgroup>
    </select>
   <br />
    <embed name="musicplayer" src="gallery/audio/midi-1.mid" width="120" height="45" hidden="false" autostart="true" loop="true">


<script language="javascript">

function MusicChange(list)
  {
   document.musicplayer.src = "gallery/audio/" + list.value;
  }

</script>
0
Comment
Question by:idiots
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 32

Accepted Solution

by:
Batalf earned 252 total points
ID: 13584419
I have searched the net for a solution to your problem, but it's not easy to find. Someone else could probably provide you with a better solution than mine.

This is just a workaround:



<body>
<script language="javascript">

function MusicChange(list){
    document.getElementById('myDiv').removeChild(document.getElementById('myDiv').childNodes[0]);
    var obj = document.createElement('EMBED');
    obj.src = list.value;
    obj.width = 120;
    obj.height = 45;
    obj.hidden = false;
    obj.autostart  = '1';
    obj.loop = 'false';
    document.getElementById('myDiv').appendChild(obj);  
}
</script>
<br />
    <select name="musiclist" onchange="javascript:MusicChange(this);">
     <optgroup label="WMA">
      <option value="WMA-1"> Unknown </option>
     </optgroup>
     <optgroup label="MP3">
      <option value="MP3-1"> The Reason </option>
     </optgroup>
     <optgroup label="MIDI">
      <option value="Midi-1.mid" selected> Midi-1 </option>
      <option value="Midi-2.mid"> Midi-2 </option>
      <option value="Midi-3.mid"> Midi-3 </option>
     </optgroup>
    </select>
   <br />
   <div id="myDiv">
    <embed id="musicplayer" src="gallery/audio/midi-1.mid" width="120" height="45" hidden="false" autostart="true" loop="true">
   </div>

</body>
</html>

0
 
LVL 1

Assisted Solution

by:xaviesh
xaviesh earned 249 total points
ID: 13584914
Please check this out ....

http://developer.irt.org/script/sound.htm
0
 
LVL 8

Assisted Solution

by:craigwardman
craigwardman earned 249 total points
ID: 13616881
the img tag can now display sound/video clips by setting the dynsrc attribute..

<img dynsrc="mid1.mid" id="musicplayer">

then the script can simply be:


document.getElementById('musicplayer').dynsrc=list.value;


I havent tested that, so you may need to change it slightly, but that should point you in the right direction..
0
 

Author Comment

by:idiots
ID: 13687063
It can't help ...
and I don't know whose post is better...
so i'll split points ...

thanks...
0
 

Author Comment

by:idiots
ID: 13687072
and I can't give A:Excellent for this question...
so i gave a B instead...
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question