HTML Media elements and their working.

HTML Media elements and their working.

Web pages often contain multimedia elements of different types and formats.Multimedia elements (like audio or video) are stored in media files.The most common way to discover the type of a file, is to look at the file extension.

The different types of media available for using in HTML are:

  1. Audio

  2. Video

  3. Plugins

  4. Youtube

  1. Audio :

The HTML <audio> element is used to play an audio file on a web page

E.g. <audio controls autoplay>

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

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

Your browser does not support the audio element.

</audio>

Working:

The controls attribute adds audio controls, like play, pause, and volume.

The <source> element allows you to specify alternative audio files which the browser may choose from. The browser will use the first recognized format.

The text between the <audio> and </audio> tags will only be displayed in browsers that do not support the <audio> element.

  1. Video:

The HTML <video> element is used to show a video on a web page.

E.g <video width="320" height="240" controls>

<source src="movie.mp4" type="video/mp4">

<source src="movie.ogg" type="video/ogg">

Your browser does not support the video tag.

</video>

Working:

The controls attribute adds video controls, like play, pause, and volume.

It is a good idea to always include width and height attributes. If height and width are not set, the page might flicker while the video loads.

The <source> element allows you to specify alternative video files which the browser may choose from. The browser will use the first recognized format.

The text between the <video> and </video> tags will only be displayed in browsers that do not support the <video> element.

  1. Plug-Ins:

Plug-ins are computer programs that extend the standard functionality of the browser.

They were designed to be used for many different purposes:

  • To run Java applets

  • To run Microsoft ActiveX controls

  • To display Flash movies

  • To display maps

  • To scan for viruses

  • To verify a bank id.

  1. Youtube:

We can use youtube id to refer to our video in the HTML code.

To play your video on a web page, do the following:

  • Upload the video to YouTube

  • Take a note of the video id

  • Define an <iframe> element in your web page

  • Let the src attribute point to the video URL

  • Use the width and height attributes to specify the dimension of the player

  • Add any other parameters to the URL

E.g : <iframe width="420" height="315"

src="https://www.youtube.com/embed/tgbNymZ7vqY">

</iframe>