..


Sponsored Links

Media with HTML5 video and audio tags

Article written by Stefano Cancedda
Page 1 of 2

Among the news that the 'HTML 5 features than previous versions, there is the possibility to directly call the dedicated multimedia content via tags.
Previously, the inclusion of this type of content within an HTML page required, in most cases, the use of external files (not standard) such as Adobe Flash. The alternative to Flash was subjected to highly restrictive conditions with regard to multimedia, today's conditions to be unfit to meet the minimum specifications required by many of the services of Web 2.0 (think, for example, YouTube).

With the advent of these features are integrated into the HTML5 language. The main tags that are relevant to multimedia:

  • <audio>
  • <video>
Referring to reference the official W3C illustrate the use of these tags riferrimento doing, also, for practical examples.

The tag <audio>

The tag <audio> defines everything that has to do with sound as, for example, music or other sounds.

In addition to the standard attributes (the list is readily available on the Net, for example on the site w3cschools.com ) the audio tag supports the following specific properties:

  • autoplay: if this attribute is present, the game will automatically play the audio file;
  • controls: if declared, will display controls such as Play and Stop buttons;
  • loop: if used, determines the loop (repetition) of music files when finished;
  • preload: if present, the audio file will be preloaded when the page loads, so as to be ready to play without expectations. If the autoplay attribute is declared, preload is ignored;
  • src: Specifies the URL of the audio file to play.





 <audio src="driin.ogg" autoplay="autoplay" controls="controls">



  



 Your browser does not support audio managed with HTML5.







 </ Audio>



The tag also supports <audio> the ability to manage more than one source, in which case the src attribute is omitted, and lurking within the <audio> tags, tags <source> this:





 <audio controls="controls">



  



 <source src="canzone1.ogg" type="audio/ogg">



  



 <source src="canzone2.mp3" type="audio/mpeg">



  



 Your browser does not support audio managed with HTML5.







 </ Audio>



Note: currently supported audio formats are mp3, wav and ogg.

Below is a screenshot made with Firefox:

In the same category ...
E-Learning
CSS (Course) CSS (Course)
Web Design and Accessibility according to W3C CSS and XHTML. Starting from 29 €.
HTML (Course) HTML (Course)
The markup language for the Web from 29 €.
Web Design (Course) Web Design (Course)
Design Web Sites with HTML, CSS and Dynamic HTML. From 39 €.
Sponsored Links