我正在尝试从列表中运行视频我已经使用两个按钮从列表中运行下一个上一个视频,默认情况下它运行第一个但它给我错误,我也变得混乱也所以我需要帮助使它运行让我告诉我的视频列表代码,
<div>
<SELECT id=cancion onchange=PlayIt() size=20 name="cancion" style="width: 470; color:#C0C0C0; height:22; background-color:#000000;">
<option value=Peace1.wmv>. . Countdown</option>
<option value=Fire.wmv>. . Time Crisis 4</option>
<option value=Water.wmv>. . Need For Speed</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/assessment.wmv>. . Meli's Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/k_0001.wmv>. . Keldin's Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/Skateboard_Tricks_Video.wmv>. . Chris's Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/video_0001.wmv>. . Salinina's Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/JORDAN_MOVES_23.wmv>. . Josh's Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/robots_video_0001.wmv>. . Sam's Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/Unexpected2.wmv>. . Unexpected</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/By_brendan_wu.wmv>. . Brendan's Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/rebecca01.wmv>. . Rebecca's Video 1</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/rebecca_robots002.wmv>. . Rebecca's Video 2</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/robotics_videoo_002.wmv>. . Robotics Video</option>
<option value=http://liamalexander.com/computing/gallery/albums/video/joys_01.wmv>. . The Joys of Spring</option>
</SELECT>
</div>
我们接下来有两个按钮用于切换视频,
<button type="button" onclick="showDiv(1 - 1)">Previous</button>
<button type="button" onclick="showDiv(1 + 1)">Next</button>
现在将在下一个或上一个按钮
上运行的脚本function showDiv(which) {
var currentImage = 1;
for(i = 0; i < 13; i++) {
//document.getElementById("image"+i).style.display="none";
document.getElementById("music1").innerHTML='<object id="mediaPlayer" width="470" height="400" '
+'classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" '
+'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '
+'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
+'<param name="fileName" value="'+document.getElementById('cancion'+i).value+'">'
+'<param name="animationatStart" value="true">'
+'<param name="transparentatStart" value="true">'
+'<param name="autoStart" value="1">'
+'<param name="showControls" value="true">'
+'<param name="loop" value="true">'
+'<param name="ShowStatusBar" value="true">'
+'<param name="ShowPositionControls" value="true">'
+'<param name="enableContextMenu" value="1" />'
+'<param name="fullScreen" value="0" />'
+'<embed type="application/x-mplayer2" '
+'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
+'bgcolor="darkblue" showcontrols="true" showpositioncontrols="true" showstatusbar="true" showgotobar="true" width="470" height="400" '
+'src="'+document.getElementById('cancion'+i).value+'" autostart="true" designtimesp="5311" loop="true">'
+'</embed>'
+'</object>'
}
//in the next 2 lines, you make sure which isn't lower than 1, and isn't greater than the number of images
if(which < 1) which = 1;
if(which > 13) which = 13;
document.getElementById("image" + which).style.display = "block";
currentImage = which;
}
我正在使用三个视频“Peace1”“Fire”“Water”你可以使用任何视频来检查此代码
希望很快收到你的回复
答案 0 :(得分:1)
以下是您应该使用的脚本:
<script type="text/javascript">
var currentTrack = 1;
function showDiv(direction) {
if(direction == "prev") {
// previous pressed
if(currentTrack > 1) {
currentTrack--;
}
} else {
// next pressed
if(currentTrack < 13) {
currentTrack++;
}
}
document.getElementById("image" + currentTrack).style.display = "block";
document.getElementById("music1").innerHTML='<object id="mediaPlayer" width="470" height="400" '
+'classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" '
+'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '
+'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
+'<param name="fileName" value="'+document.getElementById('cancion').options[currentTrack].value+'">'
+'<param name="animationatStart" value="true">'
+'<param name="transparentatStart" value="true">'
+'<param name="autoStart" value="1">'
+'<param name="showControls" value="true">'
+'<param name="loop" value="true">'
+'<param name="ShowStatusBar" value="true">'
+'<param name="ShowPositionControls" value="true">'
+'<param name="enableContextMenu" value="1" />'
+'<param name="fullScreen" value="0" />'
+'<embed type="application/x-mplayer2" '
+'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
+'bgcolor="darkblue" showcontrols="true" showpositioncontrols="true" showstatusbar="true" showgotobar="true" width="470" height="400" '
+'src="'+document.getElementById('cancion').options[currentTrack].value+'" autostart="true" designtimesp="5311" loop="true">'
+'</embed>'
+'</object>'
}
</script>
按钮也相应改变了:
<button type="button" onclick="showDiv('prev')">Previous</button>
<button type="button" onclick="showDiv('next')">Next</button>
我想告诉你的一些事情:
1.属性使用“”或“”
2.不要做onclick =“”,通过javascript绑定事件处理程序(我已经离开了示例,所以你可以学习一些东西,寻找你如何绑定事件处理程序的答案)