Playing video and audio with HTML5

by , Jul. 23, 2010 at 07:39 PM

Scripts: html5

Playing video and audio on the web has been made easy with the new HTML5.
The upcoming of HTML5 promises much in the webdesigning. To play an audio file or a video file on your html file is made very simple with only the element <video> or <audio>, and of course in combination with some of their useful attributes like autobuffer, autoplay, controls ....
Although the HTML5 is still in draft at the W3C. You can still use it and editing your HTML files in HTML5 cause some browsers's new version like Firefox 3.5, ... has introduced HTML5 in their browsers except the IE8.  You have however to manually code in HTML5 because
as long as it is still in the draft, no HTML editor has implement it yet except TopStyle 4 of Mozilla labs. But, soon it will be standard and will boost the work of the webdesigner.
Anyway there are out there on the internet enough documentations about HTML5 and its tags.
You ougth to know HTML5 will drastically improve on the structuring the html file by sectioning the file.
The strucure the document in XHTML like:
<body>
   <div id="header"></div>
   <div id="nav"></div>
   <div id="content">
          <div id="article1"></div>
          <div id="article2"></div>
          <div id="article3"></div>
    </div>
    <div id="footer"></div>
</body>

will change in HTML5 as follows:
<body>
   <header>
   <nav>
   <section id="content">
        <article1>
        <article2>
        <article3>
   <footer>
</body>

But in this topic, i like to share with you how you can too use the video tag of this great tool of designing your websites.
Note you don't have to embed third part objects like Flash, Applet,... in order to play your video or audio.

For this example, i made an movie my mobile phone and upload it to my server. Then i can play it directly on the browser without further
editing with Flash,... So simple is that!
But all the browsers are not yet implement HTML5. For example Firefox 3.5 and Opera 10.50 can play .OGG or .OGV, open format voor video,
Internet explorer 8 does not implement HTML5, the up-coming Internet Explorer 9 is well promising to implement it and the video format it will play is MP4.
Google Chrome has completely implemented HTML5 and plays .OGG, .MP4, .WebM video formats.
Safari plays .MP4 video's.
Here is the code of the HTML5 I edit to play my muvee on the browser.
See, the structure of HTML5 is simple:

  1. <!DOCTYPE html>
  2. <meta charset="utf-8" />
  3. <title>My HTML5 Video</title>
  4. <style type="text/css">
  5. .cadre{ padding: 10px;
  6. float: left;
  7. width :400px;
  8. border:1px solid #ddd;
  9. background-color: #efefef;
  10. -moz-border-radius:10px;
  11. -webkit-border-radius:10px;
  12. }
  13. video{
  14. float: left;
  15. width :400px;
  16. }
  17. </style>
  18. </head>
  19. <div class="cadre">
  20. <video controls autoplay poster='media/hizkia.jpg'>
  21. <source src='media/test.ogg' type='video/ogg'>
  22. <source src='media/test.mp4' type='video/mp4'>
  23. Sorry your browser doesn't support HTML5 yet!
  24. </video>
  25. </div>
  26. </body>
  27. </html>

This is a good news for webdesigners that HTML5 can play video and audio on the web. It works also in RSS readers (no need JavaScript), on the iPhone / iPad (don’t support Flash) and on many, many browsers and platforms.
And if you want to watch the demo of this code. Click on this link demostration.
Have fun.

Available Comments :

Your Attention! Please do not post message with spam on this blog. We try to be cool to each other and post relevant comments and relating to the appropriated topic or entry. Let's try to get a nice conversation over here.

Leave a comment

Required!
Required!

Required!
Required!

Latest News

  • Jul. 29, 2014 at 18:38
    Watch the latest news summary from BBC World News. International news updated 24 hours a day.
    Read more»
  • Jul. 29, 2014 at 18:36
    A major West African airline halts flights to Liberia and Sierra Leone amid growing concern about the spread of the deadly Ebola virus.
    Read more»
  • Jul. 29, 2014 at 18:32
    Muslims around the world celebrate Eid
    Read more»
  • Jul. 29, 2014 at 18:25
    The EU imposes new economic sanctions on Russia over the conflict in Ukraine, going beyond asset freezes and travel bans.
    Read more»
  • Jul. 29, 2014 at 18:21
    A ban on steel-string guitars in prison cells in England and Wales is reversed after a campaign by rock stars including Billy Bragg and John...
    Read more»
  • Jul. 29, 2014 at 18:20
    The parents of Liam Sweeney, one of the Britons who died in the MH17 air crash, have said they are "angry and frustrated" at not knowing wha...
    Read more»
  • Jul. 29, 2014 at 18:11
    Liverpool complete the £10m signing of Belgium striker Divock Origi from French club Lille on a five-year deal.
    Read more»
  • Jul. 29, 2014 at 17:42

    Read more»
  • Jul. 29, 2014 at 17:32
    Liberia suspends all football activities in an effort to control the spread of Ebola, as the number of people killed by the virus in West Af...
    Read more»
  • Jul. 29, 2014 at 17:29
    A group representing musicians in the US is suing Ford and General Motors over in-car CD players which allow tracks to be stored on a hard d...
    Read more»
  • Jul. 29, 2014 at 17:24
    The US collegiate sport authority offers to settle 10 lawsuits by former athletes who suffered concussions with a $70m (£41.3m) medical fun...
    Read more»
  • Jul. 29, 2014 at 17:22
    China's former security chief Zhou Yongkang has been placed under investigation for "serious disciplinary violation", state media say.
    Read more»
  • Jul. 29, 2014 at 17:16
    Britain is to cut from six to three months the amount of time out-of-work EU migrants can claim benefits without realistic job prospects.
    Read more»
  • Jul. 29, 2014 at 17:16
    Dozens of people have been killed or injured in an attack in China's troubled western region of Xinjiang, state media say.
    Read more»
  • Jul. 29, 2014 at 17:11
    Lawyers for Bernie Ecclestone say the Formula 1 boss is ready to pay a German bank 25 million euros ($34m; £20m) to settle a court case aga...
    Read more»
  • Jul. 29, 2014 at 17:01
    More than 100 Palestinians die, officials say, as Israel intensifies its bombardment of Gaza after PM Netanyahu warns of a long conflict ahe...
    Read more»
  • Jul. 29, 2014 at 16:50
    A selection of images from around the world over the past 24 hours
    Read more»
  • Jul. 29, 2014 at 16:47
    Dating website OKCupid reveals that it experimented on its users, including putting the "wrong" people together to see if they would connect...
    Read more»
  • Jul. 29, 2014 at 16:39
    How Zhou Yongkang case tears up rulebook of Chinese politics
    Read more»
  • Jul. 29, 2014 at 15:54
    England win gold in the men's gymnastics team final as Scotland land a historic silver medal.
    Read more»

Recent Comments:

Ehcjntublr

Jun. 11, 2014 at 06:06 PM

leebvfnnbovfmoebzjsbhjkf, http://www.pykbyrhrlo.com/ spdwthctlr

Natural hair care products

May. 27, 2014 at 09:05 AM

These are really great ideas in on the topic of blogging. You have touched some pleasant things here. Any way keep up wrinting.

Remedies for piles

May. 18, 2014 at 05:44 PM

Thanks for finally writing about > %blog_title% < Loved it!

Website

Mar. 25, 2014 at 08:19 PM

There are books, home study courses, workshops and other means of information, to gain the knowledge required to become the alpha leader. If you want ... Read more»

Titia

Feb. 15, 2014 at 01:48 AM

buy car insurance online prozac 40mg no rx best deals on vigra and cialis website auto insurance quoye www.evansvillecommunitytheatre.com ... Read more»

Archives:

Meet me on facebook: