Audio and Video Tags

Audio and Video Tags

๐Ÿ”‰ Audio and ๐Ÿ“น Video

ยท

2 min read

Video Tag in HTML๐Ÿ“น

The ๐Ÿ“น video tag in HTML embeds a media player

However, it has the following properties

  • src : Where the path(relative) of the video ๐Ÿ“น is given. It can also be the URL.

  • controls : This attribute will give you the controls i.e. Buttons to use the features of the media player i.e. โ–ถ play , pauseโธ, forward, full-screen, download, picture-in-picture.

  • type : This refers to the type of video that we are going to add i.e. extension (mp4,)

  • autoplay : It will autoplay your video ๐Ÿ“น when the page is being loaded.

  • loop : It will keep playing the video ๐Ÿ“น in a loop and also has a boolean value, the default value is false.

  • ๐Ÿ”• muted : It has a boolean(true / false) value, where its default value is false the video will not be played even if auto-play is added and muted is not as an attribute.

  • Also, you can provide inline styling.

<!DOCTYPE html>
<html lang="en">
  <head>
  <title>Video</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  </head>
  <body>
    <video
      src="/HTML/video/video-demo.mp4"
      width="400"
      type="video/mp4"
      controls
      muted="false"
      style="background-color: #777; padding: 20px"
      autoplay="true"
      loop
    ></video>
  </body>
</html>

๐Ÿ”‰Audio Tag in HTML

  • The audio ๐Ÿ”‰ tag will embed the sound content in the document ๐Ÿ“„.

  • And it will have the following attributes.

  • src : will have a path (relative)or link ๐Ÿ”— where the audio file is been ๐Ÿฌ stored.

  • type: audio, mpeg , ogg are the types of audio files ๐Ÿ“‚ which can be added over.

  • ๐ŸŽฎ controls : will add all the controls to play โ–ถ , pause โธ, seek.

  • autoplay: will play the sound/audio as soon as the page is loaded.

  • โžฟ loop: will keep playing the audio in the loop.

  • muted ๐Ÿ”•: It's an attribute with a boolean value where the option to mute the audio ๐Ÿ”‰ is provided when the page is loaded.

<!DOCTYPE html>
<html lang="en">
  <head>
  <title>Audio Tag in HTML</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  </head>
<body>
 <audio src="/HTML/sound/beats.mp3" controls autoplay loop></audio>
</body>
</html>

Thanks for reading.

Did you find this article valuable?

Support Moreshwar's Blogs by becoming a sponsor. Any amount is appreciated!

ย