changing video in embedded player

hillelben
hillelben used Ask the Experts™
on
i want to have one embedded player probably windows media player and a list of links of avi videos.  when they click on a link i want this to change this to the video that gets played in the player.  How do you change video that being played with js?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
try using a script like below.

You may refer to http://msdn.microsoft.com/en-us/library/ms983998.aspx

    <object id="MediaPlayer" width="320" height="245" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
        standby="Loading Windows Media Player components..." type="application/x-oleobject">
        <param name="FileName" value="http://place_your_video_file_url">
        <param name="autostart" value="false">
        <param name="ShowControls" value="true">
        <param name="ShowStatusBar" value="false">
        <param name="ShowDisplay" value="false">
        <embed type="application/x-mplayer2" src="http://place_your_video_file_url"
            name="MediaPlayer" width="320" height="245" showcontrols="1" showstatusbar="0"
            showdisplay="0" autostart="0"> </embed>
    </object>

Open in new window

Hope this helps.      

Author

Commented:
what i'm really looking for is javascript to make the player switch from one video to another

thanks
This is somewhat of an old code but I think it is what you are looking for.

You will want to change the paths to the proper paths for your media on lines 2,3,4,5, and 51

This JS might been to be updated, I have not used it in a couple of years.  Basically though, it would start to play the default (line 51).  Under the player you should see a dopdown for the songs referenced in lines 2,3, and 4
<script language="javascript">var streams = new Array();
streams[0] = new makeStream("dreamer.wav", "1...I'm Just a Dreamer - Ozzy Osbourne");
streams[1] = new makeStream("albatross.wav", "2...Albatross - Fleetwood Mac");
streams[2] = new makeStream("somevelvetmorn.wav", "3...Some Velvet Morning - Nancy Sinatra and Lee Hazelwood");
streams[3] = new makeStream("bestieverhad.wav", "4...Grey Sky Morning - Vertical Horizon");
function makeStream(url, name) {
 this.url = url;
 this.name = name;
}
function handleControlsOnOffClick() {
  if (document.mediaPlayer.showControls == true) {
    document.mediaPlayer.showControls = false;
   document.playerCtrl.controls.value = "  :.SHOW PLAYER.:";
  }
  else {
    document.mediaPlayer.showControls = true;
   document.playerCtrl.controls.value = "  :.HIDE PLAYER.: "
  }}
function handlePlayOrPauseClick(){
  var state;
  playerStatus = document.mediaPlayer.playState;
  if (playerStatus == 6) {
    document.mediaPlayer.play();
    document.playerCtrl.playOrPause.value = " :.PAUSE.: ";
  }
  else if (playerStatus == 1) {
    document.mediaPlayer.play();
    document.playerCtrl.playOrPause.value = " :.PAUSE.: ";
  }
  else if (playerStatus == 2) {
    document.mediaPlayer.pause();
    document.playerCtrl.playOrPause.value = " :.PLAY.:  ";
  }
}
function changeSize(newSize) {
  document.mediaPlayer.displaySize = newSize;
}
function change() {
  var list = document.playerCtrl.streams;
  var streamURL = list.options[list.selectedIndex].value;
  document.mediaPlayer.stop();
  document.playerCtrl.playOrPause.value = " :.PAUSE.: ";
  document.mediaPlayer.fileName = streamURL;
}
</script>

<object id="mediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
codebase=" http://activex.microsoft.com/activex/controls/mplayer/en/nsm p2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft Windows Media Player components..."
type="application/x-oleobject" width="239" height="179">
  <param name="fileName" value="sounds/bestieverhad.wav">
  <param name="animationatStart" value="false">
  <param name="transparentatStart" value="true">
  <param name="autoStart" value="true">
  <param name="loop" value="true">
  <param name="showControls" value="false">
</object>

<form name="playerCtrl">
  <input type="button" value=" :.PAUSE.: " name="playOrPause"
  onclick="handlePlayOrPauseClick()" style="font-family:courier"> <input
  type="button" value="  :.SHOW PLAYER.: " name="controls"
  onclick="handleControlsOnOffClick()" style="font-family:courier">

<script language="javascript">
with (document) {
  writeln('<select name="streams" onChange="change()">');
  for (var i = 0; i < streams.length; i++) {
    writeln('<option value="', streams.url, '">', streams.name);
  }
  writeln('</select>');
}
</script>
</form>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial