我已经尝试让它工作了几天,研究如何做到这一点,一遍又一遍地改变它,但它就是行不通。我要么愚蠢要么盲目。我想编写一个简单的视频播放器...我认为对于初学者来说这很容易 T_T
这是html文件:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<script language="JavaScript" src="player.js"></script>
</head>
<body onkeydown="GetKey()" onload="VideoList()">
<div style="text-align:center">
<img src="images/Magipoka.jpg" onclick="window.location='Magipoka.html'">
<img src="images/puni.jpg" onclick="window.location='puni.html'">
<br>
<video id="currentVideo" autoplay="true" preload="auto" onended="Playnext()"
onclick="goFullscreen('currentVideo'); return false" ;="">
<source src="Magipoka.mp4" type="video/mp4">
<source src="Magipoka.ogv" type="video/ogv">
Your browser does not support HTML5 video.
</video>
</div>
<div style="text-align:center">
<button onclick="LoopToggle()">Loop</button>
<button onclick="LoopToggleOff()">LoopOff</button>
<button onclick="playPause()">Play/Pause</button>
</div>
<script language="JavaScript" src="Body_Scripts.js"></script>
</body>
</html>
正文 js 文件:
var Video=document.getElementById("currentVideo");
var VideoCount = 0;
var source = new Array();
function VideoList(){
source[0].src = "Magipoka.ogv";
source[1].src = "puni.ogv";
}
function playPause()
{
if (Video.paused)
Video.play();
else
Video.pause();
}
function LoopToggle(){
if (Video.ended)
Video.play();
if(Video.loop="false")
video.loop=true;
else
video.loop=null;
}
function Repeat(){
if(Video.ended)
Video.paused();
Video.play();
}
function Playnext(){
Video.src = source[VideoCount];
//alert(VideoCount);
VideoCount++;
alert(source[1]);
}
头js文件:
function goFullscreen(id) {
// Get the element that we want to take into fullscreen mode
var element = document.getElementById(id);
// These function will not exist in the browsers that don't support fullscreen mode yet,
// so we'll have to check to see if they're available before calling them.
if (element.mozRequestFullScreen) {
// This is how to go into fullscren mode in Firefox
// Note the "moz" prefix, which is short for Mozilla.
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
// This is how to go into fullscreen mode in Chrome and Safari
// Both of those browsers are based on the Webkit project, hence the same prefix.
element.webkitRequestFullScreen();
}
// Hooray, now we're in fullscreen mode!
}
//-----------------
function GetKey(e) { var code; if (!e) var e = window.event; if (e.keyCode)
code = e.keyCode; else if (e.which) code = e.which; var character =
String.fromCharCode(code); setTimeout('ShowTree('+code+');',100);
}
function ShowTree(character, a){
if (character == 49){
window.location='puni.html' }
if (character == 50){
window.location='magiPoka.html' }
}