How to inset Audio and video files in HTML using audio and video tags?
For inserting audio in HTML <audio> tag is used. In lower version of HTML embed and bgsound tags used for inserting audio files in webpage.
For inserting video in HTML <video> tag is used. In lower HTML version embed and img dynsrc are used for embedding video in webpage.
Attributes of audio tag are as follows:
1. Src : provides location or source of audio file.
2. Controls : this attribute provides an console with play, pause, forward, button as we play music on any music player.
3. Loop: this attribute used for playing audio in assigned value times if loop=2 then audio file will be played two times after finishing
4. Muted: this attribute is used for muting audio
5. Autoplay: this attribute is used for auto playing audio when user open webpage.
Source tag is used for adding multiple audio files in webpage.
Attributes of video tag are:
1. Src: this attribute specifies location of video or URL
2. Autoplay: this attribute is used for auto playing video when user open webpage.
3. Controls: this attribute provides a console for play, pause, etc. the Video.
4. Height: this attribute specifies height to the video.
5. Width: this attribute specifies width to the video.
6. Loop: this attribute used for playing video in assigned value again and again.
7. Muted: this attribute specifies that during playing video audio should muted.
8. Poster: this attribute specifies a thumbnail or image to be displayed before playing video.
9. Preload: this attribute specifies how to load video when webpage loads. It has values auto, Metadata, none. Auto means video will preloaded when webpage opens. Metadata value will load only Metadata and none will not preload video.
None value of preload attribute is equal to autoplay which means if autoplay attribute is used then preload attribute will ignored.
Similarly source tag is used for embedding multiple videos.
Height and width of audio and video output can be customized with help of CSS.
Common audio file formats:
Mp3, wav, other, aac
Common video file formats:
Mp4, ogg, webM.
Lets understand through code:
Comments
Post a Comment