Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start embedded video

Status
Not open for further replies.

conrai

Programmer
Nov 21, 2004
10
FI
Hi! I have the following problem and it would be nice if you could help me ;).

I have embedded the windows media player plugin to my site. The user can choose from a selct menu which video to play and on changing the select menu, the video should start to play.

The media player plugin:
Code:
      <OBJECT id='mediaPlayer1'
      classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' 
      codebase='[URL unfurl="true"]http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'[/URL]
      standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
      <param name='fileName' value="">
      <param name='animationatStart' value='true'>
      <param name='transparentatStart' value='true'>
      <param name='autoStart' value="true">
      <param name='showControls' value="true">
      <param name='ShowStatusBar' value="true">
      <param name='loop' value="false">
      <param name='autosize' value="1">
      <EMBED type='application/x-mplayer2' pluginspage='[URL unfurl="true"]http://microsoft.com/windows/mediaplayer/en/download/'[/URL] id='mediaPlayer2' src="" Name='MediaPlayer2' ShowControls=1 ShowDisplay=0 ShowStatusBar=1 width="350" height="350" bgcolor='darkblue'> </EMBED>
      </OBJECT>
The select menu:
Code:
<select name="videos" id="goToVideo" size="1" onChange="showVideo(this,'Please select a video!')"> 
<option>- - select video - -</option>
<option value="videos/video1.avi">video1</option>
...
</select>
The javascript function (please read comments):
Code:
<script language="javascript">
function showVideo(selObj, noselectionWarning){
  var newIndex = selObj.selectedIndex; 
  if ( newIndex == 0 ) { 
    alert(noselectionWarning);
  } else {
    // for Internet explorer -> THIS WORKS! Video 
    // starts automatically:
    document.getElementById('mediaPlayer1').fileName = selObj.options[newIndex].value;
    // YET NOT for Firefox, i can set the source, and the 
    // autostart attribute, yet the video does not start
    // automatically:
    document.getElementById('mediaPlayer2').src =  selObj.options[newIndex].value;
document.getElementById('mediaPlayer2').autostart = true;
}
</script>
Do you have an idea, how i can get the video starting?

Thanks for your help!
Conrad
 
Have you tried adding the autostart property to the embed element:

Code:
<EMBED type='application/x-mplayer2' pluginspage='[URL unfurl="true"]http://microsoft.com/windows/mediaplayer/en/download/'[/URL] id='mediaPlayer2' src="" Name='MediaPlayer2' ShowControls=1 ShowDisplay=0 ShowStatusBar=1 width="350" height="350" bgcolor='darkblue' [b]autostart='true'[/b]>

I've not tried it, but it's worth a go.

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]
 
Thanks, I solved the problem now..
Autostart alone didn't work, i changed the Javascript function:

Code:
function showVideo(selObj, noselectionWarning){
  var newIndex = selObj.selectedIndex; 
  if ( newIndex == 0 ) { 
    document.getElementById('mediaPlayer1').fileName = '';
    document.getElementById('mediaPlayer1').style.display = 'none';
} else {
document.getElementById('mediaPlayer1').style.display = 'none';
document.getElementById('mediaPlayer1').style.display = 'inline';
document.getElementById('mediaPlayer1').fileName = selObj.options[newIndex].value;
document.getElementById('mediaPlayer2').src = selObj.options[newIndex].value;
document.getElementById('externalLink').href = selObj.options[newIndex].value;
  }
}

br,
..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top