html 5简易的影片播放器
<!DOCTYPE html > <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>简易影片播放器</title> <script type="text/javascript"> function playOrPauseVideo(){ var videoUrl=document.getElementById("videoUrl").value; var video=document.getElementById("video"); //影片不为播放状态 if(video.paused) { //URL改变时,重新加载 if(videoUrl!=video.src) { video.src=videoUrl; video.load(); } else {//播放 video.play() } document.getElementById("playButton").value="暂停"; } else { //暂停 video.pause(); document.getElementById("playButton").value="播放"; } } </script> </head> <body> <video id="video" width="400" height="300" autoplay></video><br /> 影片的URL:<input type="text" id="videoUrl"/> <input id="playButton" type="button" onclick="playOrPauseVideo()" value="播放"/> </body> </html>