成人论坛

Implementation: HTMLVideo and audio elements

The main structure of an HTML page makes use of <head>, <title> and <body> tags. Implementation of HTML through use of titles, videos, audio, div, anchor, headings, paragraphs and links provides a solid basis for future implementation.

Part of Computing ScienceWeb design and development

Video and audio elements

Video

&濒迟;惫颈诲别辞&驳迟;鈥&濒迟;/惫颈诲别辞&驳迟;

In HTML5 video clip are added as follows:

<video width="320" height="240" autoplay>
      <source src="movie.mp4" type="video/mp4">
</video>

In this example, the height and width is defined and the autoplay attribute is activated. MP4 videos are compatible with all major browsers. However, there are two other video formats that can be used in HTML5 鈥 ogg and webm. The browser would try to play the mp4 file but if it could not be found the browser would try to play the ogg file and so on.

<video width="320" height="240" autoplay>
      <source src="bitesizeclip.mp4" type="video/mp4">
      <source src="bitesizeclip.ogg" type="video/ogg">
      <source src="bitesizeclip.webm" type="video/webm">
</video>

Audio

&濒迟;补耻诲颈辞&驳迟;鈥&濒迟;/补耻诲颈辞&驳迟;

In HTML5 audio clips are added as follows:

<audio controls>
      <source src="bitesizetheme.mp3" type="audio/mpeg">
      <source src="bitesizetheme.ogg" type="audio/ogg">
      <source src="bitesizetheme.wav" type="audio/wav">
</audio>

The controls attribute is used to include play, pause and stop buttons and is recommended for most audio clips. As with video, there are different audio formats that can be used with the audio element. The mp3 format is recognised by all major browsers but ogg and wav can also be used. The browser will identify the first version of the audio clip that it can interpret and will play the audio.