Introduction to Html5 the Html5 Video Element

Introduction to Html5 the Html5 Video Element

<p> INTRODUCTION TO HTML5 – THE HTML5 VIDEO ELEMENT</p><p>HTML5’s video element is conceptually easy to work with, since basically it’s been designed like the <img> tag...... just code and go: </p><p><video src="sample.mp4" width="640" height="480"></video> </p><p>Unfortunately, in the real world, things aren’t quite so easy. Due to licensing and other restrictions, you can’t simply assume that the user’s software will properly display your video in MPEG- 4/H.264 format. At this point you’ll have to supply the same video in open formats as well as providing a Flash-based fallback for pre-HTML5 browsers: </p><p>Your code will look something like this:</p><p><video controls width="640" height="480" poster="sample.jpg"> <source src="sample.mp4" type="video/mp4"> <source src="sample.ogv" type="video/ogg"> <source src="sample.webm" type="video/webm"> <object width="640" height="480" type="application/x- shockwave-flash" data="player.swf"> <param name="movie" value="player.swf"> <param name="flashvars" value="controlbar=over&amp;image=sample.jpg&amp;file= sample.mp4"> </object> </video> <p> <strong>Download Video:</strong> Closed Format: <a href="sample. mp4">"MP4"</a> Open Format: <a href="sample.ogv"> "Ogg"</a> WebM Format: <a href="sample. webm"> "WebM"</a> </p> </p><p>06891f69406683d0b431b6bfeaf849b7.doc Version 1 Page 1 of 5 Since this isn’t the kind of thing most developers like to memorize, it’s good that someone has written up a handy free code generator that lets you specify all your parameters and video sizes and so on. See http://v4e.thewikies.com/</p><p>Preaching to the Converted </p><p>Unless you have lots of video files and an actual software budget, your best bet is free conversion software. Currently, the best selection for that is Handbrake, which is fully open source, runs on Windows, Mac OS X and Linux, and will convert most multimedia file formats to MP4 or Ogg Theora. When we get to audio, you’ll find that it works just as well for those formats, too. If you’d rather be modern, OS-independent, and stay in the cloud, sites such as MediaConverter and Zamzar can accommodate you with free online transcoding services. The latter site even supports the relatively new WebM format. </p><p>The full list of attributes for the HTML5 video element at this time includes the following, with usage notes: o src - The URL of the video. This overrides the source element, if present. o poster - The URL of a still picture to show while the video is not playing. o preload - This can have the value none, metadata, or auto. Auto will download the entire file if possible; metadata will download just the parameters so that the length, size, and type of the video can be identified, and none will do nothing, which saves bandwidth. o autoplay - This boolean, if present, triggers the video to play as soon as it is fully buffered or ready to stream. o loop - Also a boolean; if loop is present, the video will repeat endlessly in the absence of user intervention. o audio - This attribute, which controls the audio portion of the video, is still in development. Currently, it can take only a single value: muted, which means that the audio volume will initially be set to zero. The intent is to allow an autoplaying video to start and get the user’s attention, but without blaring audio that would cause the user to close the entire tab in disgust :-) </p><p>06891f69406683d0b431b6bfeaf849b7.doc Version 1 Page 2 of 5 o controls - A boolean attribute that specifies the browser should provide a set of default video controls. If it doesn’t appear, you’ll have to design and code your own controls. o width, height - These size attributes control the size of the area reserved for the video on the page, but not necessarily its exact dimensions. </p><p>You might like to use JavaScript to create your own controls and error handling, but all it takes is some CSS to modify the look of the video element: </p><p><!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>File in same directory</title> <style type="text/css"> video { width: 800px; height: 600px; position: relative; } </style> </head> <body> <p> <video source src="sample.webm" controls autoplay> Your browser does not support the video tag. </video> </p> </body> </html></p><p>Try It Yourself</p><p>You can use Notepad++ or Dreamweaver for this short exercise.</p><p>1. Create a new HTML file saving the file as video.html. Enter the basic HTML5 elements if necessary, and then enter the following:</p><p>[Source Code for Big Buck Bunny] [Note that this code can be copied and pasted from http://v4e.thewikies.com/</p><p><!-- "Video For Everybody" http://camendesign.com/code/video_for_everybody --></p><p>06891f69406683d0b431b6bfeaf849b7.doc Version 1 Page 3 of 5 <video controls="controls" poster="http://sandbox.thewikies.com/vfe- generator/images/big-buck-bunny_poster.jpg" width="640" height="360"> <source src="http://clips.vorwaerts- gmbh.de/big_buck_bunny.mp4" type="video/mp4" /> <source src="http://clips.vorwaerts- gmbh.de/big_buck_bunny.webm" type="video/webm" /> <source src="http://clips.vorwaerts- gmbh.de/big_buck_bunny.ogv" type="video/ogg" /> <object type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer- 3.2.1.swf" width="640" height="360"> <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer- 3.2.1.swf" /> <param name="allowFullScreen" value="true" /> <param name="wmode" value="transparent" /> <param name="flashVars" value="config={'playlist': ['http%3A%2F%2Fsandbox.thewikies.com%2Fvfe- generator%2Fimages%2Fbig-buck-bunny_poster.jpg', {'url':'http%3A%2F%2Fclips.vorwaerts-gmbh.de %2Fbig_buck_bunny.mp4','autoPlay':false}]}" /> </object> </video> <p> <strong>Download video:</strong> <a href="http://clips.vorwaerts- gmbh.de/big_buck_bunny.mp4">MP4 format</a> | <a href="http://clips.vorwaerts- gmbh.de/big_buck_bunny.ogv">Ogg format</a> | <a href="http://clips.vorwaerts- gmbh.de/big_buck_bunny.webm">WebM format</a> </p></p><p>2. Save and view the file in a range of browsers. </p><p>06891f69406683d0b431b6bfeaf849b7.doc Version 1 Page 4 of 5 06891f69406683d0b431b6bfeaf849b7.doc Version 1 Page 5 of 5</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us