Search code examples
javascripthtmlmedia-player

How to add the "src" dynamically and start/stop playing


<EMBED  id = "player"
                        TYPE="application/x-mplayer2" 
                        NAME="MediaPlayer" 
                        WIDTH="192" 
                        HEIGHT="190" 
                        ShowControls="1" 
                        ShowStatusBar="0" 
                        ShowDisplay="0" 
                        autostart="0"> 
</EMBED>

I tried

document.getElementById("player").src = "http://localhost/abc/test.wmv";

it does not work

what should i do?


Solution

  • You should be able to do this with the setAttribute method like this...

    document.getElementById("player").setAttribute("src", "http://localhost/abc/test.wmv");