/ Published in: JavaScript
Expand |
Embed | Plain Text
<!DOCTYPE html> <html> <head> <title>HTML 5 Video</title> <link rel="stylesheet" href="css/full.css" type="text/css" /> </head> <body> <div id="left"> <video> Error: Your browser does not seem to support the (x)HTML 5 <video> element.<br /> Please download: <a href="http://google.com/chrome">Google Chrome</a> (BETA) or <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Mozilla FireFox</a> (BETA). </video> <p> <a id="downloadLink">Download this video</a> (.mp4) </p> </div> <div id="right"> <h3>HTML 5 Video</h3> <p> Volume: <span id="videoVolume"></span><br /> <input type="button" value=" Up " onClick="v.volume+=0.05; volumeElement.innerHTML-=-5.0;" /> <input type="button" value=" Down " onClick="v.volume-=0.05; volumeElement.innerHTML-=5.0;" /> </p> <!-- <p> Volume: <span id="videoVolume"></span><br /> <input type="range" id="volumeRange" min="0" max="100" value="(v.volume*100)" onInput="v.volume+=(this.value/100.00); volumeElement.innerHTML-=-(this.value/100.00);" /> </p> --> </div> <!-- Lets put the script at the bottom to ensure the <video> has been loaded into the DOM. --> <script> /** * HTML 5 Video Test * * Adam Shannon * 06/13/2009 - [ 1400 CST ] * http://ashannon.us */ //************************************************************* //* Remember: * //* - The v.src is set via the URI (in PHP). * //* - The "Download This Video" link is set to v.src * //* * //* Notes: * //* - This demo only seems to work in Chrome 3.0.187.1 * //************************************************************* // Gather the video element var v = document.getElementsByTagName("video")[0]; // Set the v.src var path = "src/barack-high.mp4"; v.src = path; // Now set the download link. document.getElementById("downloadLink").href = path; // Check to see if there is an error. v.onerror = function () { alert("Whoops, it seems that there was an error, please refresh the page."); } // Set the volume (0.00 to 1.00) v.volume = 0.15; // Set the width and height (pixels). v.height = 360; v.width = 640; // Set the video to loop or not. // This can be a [bool]. v.loop = true; // Set the auto play feature // This can be a [bool] or a string set to "autoplay", // all others will be treated like a [bool] of false. v.autoplay = true; // Tell the player to auto buffer the video data. // This can be a [bool]. v.autobuffer = true; // We can set some CSS commands on the <video> v.style.opacity = 1; // Get some other elements var volumeElement = document.getElementById("videoVolume"); volumeElement.innerHTML = v.volume + ""; volumeElement.innerHTML = volumeElement.innerHTML.substr(2,2); // Make the video stop playing when its clicked. v.onclick = function () { (this.paused) ? this.play() : this.pause(); } // Check to see if the video has ended, if so play the video again. v.addEventListener("ended", function () { this.play(); } , false); </script> </body> </html>
You need to login to post a comment.
