Adding audio and video in a web page


<video> tag

The <video> tag can be used if you want the video to appear on the web page.
The controls attribute let you add video controls, like play, pause, and volume.
The <source> tag associated with this tag let you specify alternative video formats. Browser will play the video file which is been recognized firstly among the formats specified. .mp4 is the most commonly recognized video format by the several browsers.
It has following attributes:
Attributes DescriptionValues
height : Set the height of the window for video to be appear. pixels
width : Sets the width of the window in pixels or percentage of available screen resolution.pixels
name : Provides label for embedded object.text
autoplay : Sets whether the media element should start automatically or not. true or false
loop : Allows you to have the movie play continuously.
true-plays forever from start to end
false-pays once
palindrome-plays forever forwards and backwards
true, false or palindrome
controls: Specifies whether you want the media controller bar to be shown or not. true or false
The <source> tag has following attributes:
Attributes DescriptionValues
src : URL of the video file.URL
type : file format of the video file.Video/mp4, Video/WebM, Video/ogg

Now let see the eg.
<video height="315" width="420" controls="true" autoplay="true" loop="true" > <source src="flower.mp4" type="video/mp4"> <source src="flower.ogg" type="video/ogg"> </video>
Output:


<audio > tag

This tag can be used to play an audio in the HTML file.
The controls attribute let you add audio controls, like play, pause, and volume.
The <source> tag associated with this tag let you specify alternative audio formats. Browser will play the audio file which is been recognized firstly among the formats specified. .mp3 is the most commonly recognized audio format by the several browsers.
It takes following attributes :
Attributes DescriptionValues
name : Provides label for embedded object.text
autoplay : Sets whether the media element should start automatically or not. true or false
loop : Allows you to have the movie play continuously.
true-plays forever from start to end
false-pays once
palindrome-plays forever forwards and backwards
true, false or palindrome
controls: Specifies whether you want the media controller bar to be shown or not. true or false

<audio controls loop="2" >
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio >

You Might Also Like

0 comments

My photo
Hi. I am Ramesh Wetkoli. Three things I try to include in my blog posts are creativity, useful insights, and trendy information. IT graduate and working professional. I have leveraged 9+ years of work experience in IT industry and learnt various technologies, providing merchandizing support and handling digital marketing responsibilities.

Find us on Facebook