Sunday, September 4, 2011

HTML 5 audio element

HTML 5 facilitates a standard way to play audio file. As of now following audio formats are supported.
  • ogg
  • mp3
  • wav
Format:
<audio> </audio>

Attributes:

src - url of the audio file to play
autoplay - starts the audio as soon as it is ready to play
controls - whether to show controls or not
loop - repeats the play when it finishes
preload - load the audio file with page load.

Example:

<audio controls="controls">
  <source src="song.ogg" type="audio/ogg" />
  <source src="song.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>  


HTML 5 Video Element

HTML 5 facilitates a standard video element to show video in web page. As of now following video formates are supported.

  • Ogg = Ogg files with Theora video codec and Vorbis audio codec
  • MPEG4 = MPEG 4 files with H.264 video codec and AAC audio codec
  • WebM = WebM files with VP8 video codec and Vorbis audio codec
Element:

<video> </video>
Attributes:


  • src - url of the video
  • height - height of the player in pixels
  • width - width of the player in pixels
  • controls - if present player controls will be shown
  • autoplay - if present video will be started as soon as it is ready to play. Default is manual.
  • loop - if present video will be played from beginning when it finishes playing
  • poster - to show a placeholder image for player
  • preload - load the complete video at page load. This attribute is ignored if autoplay is present.
  • audio - to mute the audio

Example:

<video width="320" height="240" controls="controls" autoplay>
  <source src="movie.ogg" type="video/ogg" />
  <source src="movie.mp4" type="video/mp4" />
  <source src="movie.webm" type="video/webm" />
Your browser does not support the video tag.
</video> 









 
  • Blogroll

  • Consectetuer

  • Popular

  • Comments