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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down Box Functionality Question 1

Status
Not open for further replies.

gwillr

IS-IT--Management
Nov 4, 2003
267
CA
I have 7 diff short video clips.

My goal is to have a drop-down box, with an entry for each clip as the list. Thus, the drop-down box would have something like:

vid1
vid2
vid3 and so on as the drop-down list.

I want to have a page where a user can select the appropriate video, and click a "Submit" button.

When the button is clicked, I want the video to play, as if a link was clicked and caused it to play.

I have searched for code to accomplish this with no success. anyone with a generic code for such a situation?


Gary
 
I have done something similiar for a friend of mine. It looks something like this:
Code:
<HTML>
<HEAD>
<TITLE>Windows Media Player Control Install</TITLE>
</HEAD>
<BODY>
<script type="text/javascript">
<!--
function go1(){
if (document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value != "none") {
location = document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value
		}
	}
//-->

</script>
<CENTER>
<object id="MediaPlayer" width=320 height=286
classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
standby="Loading Microsoft® Windows® Media Player components..."
type="application/x-oleobject"
codebase="[URL unfurl="true"]http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">[/URL]
<PARAM NAME="filename" VALUE="interview_fox_video.asx">
<PARAM NAME="autoStart" VALUE="true"> <PARAM NAME="showControls" VALUE="true">
<param name="ShowStatusBar" value="true"> <PARAM NAME="Autorewind" VALUE="true">
<PARAM NAME="ShowDisplay" VALUE="false"> 
  <EMBED SRC="interview_fox_video.asx" WIDTH=320 HEIGHT=286 type="application/x-mplayer2" name=MediaPlayer autostart=1 showcontrols=0 showstatusbar=1 autorewind=1 showdisplay=0>
</EMBED></OBJECT>


<script type="text/javascript">
<!--

document.write('<form name="selecter1"><select name="select1" size=1 onchange="go1()">');
document.write('<option value=none>Select your destination');
document.write('<option value=none>--------------------');
document.write('<option value="video1.html">Video One');
document.write('<option value="video2.html">Video Two');
document.write('<option value="video3.html">Video Three');
document.write('<option value="video4.html">Video Four');
document.write('</select>');
document.write('</form>');
// end hiding contents -->


</script>
</CENTER>   
</BODY>
</HTML>
You would place the javascript on every page & change the source of the video clip (interview_fox_video.asx) in BOTH places.

__________________________
Corey

 
Thanks Corey, code works great!!

Is there any way to have a submit type buttin called "play" that one would have to click before the vid actually plays?

Gary
 
Ahhh, I should have noticed that, thank you for all your help!

Gary
 
if you are still around, I have another question about the code.

currently, it uses different pages for each clip.

I am trying to have each one play in the same page....for example, when a selection is made from the dropdown list, it will load the video file to be played in the media player.

Is something like that possible with this code?

Gary
 
That is a possibility - to dynamically change the path but in all honesty, it will probably be easier to use different pages.
Otherwise, I would have to suggest either ASP / PHP to dynamically change the path or even possibly more JavaScript.

__________________________
Corey

 
do you know how i would go about setting that up?


I'd like for each entry in the dropdown list to change the "filename" value accordingly.

<PARAM NAME="filename" VALUE="interview_fox_video.asx">

Gary
 
Well - wouldn't you know it, someone gave me some code:
Code:
<p align="Center">
<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>
<br>
<p align="Center"><br>
<br>
<br>
<p align="center">
<object id="mediaPlayer" 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" 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>
</p>
<form name="playerCtrl">
  <p align="center"><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">
  <p align="center">
<SCRIPT LANGUAGE="JavaScript">
with (document) {
  writeln('<SELECT NAME="streams" onChange="change()">');
  for (var i = 0; i < streams.length; i++) {
    writeln('<OPTION VALUE="', streams[i].url, '">', streams[i].name);
  }
  writeln('</SELECT>');
}
</SCRIPT>
  </p>
</form>

__________________________
Corey

 
HEY HEY! Excellent. This code esentially provides the exact type of functionality that I have been looking for, after a few small changes.

Thanks a bunch for your help in finding such a code!

Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top