Wednesday, June 19, 2024

HTML MEDIA

Here’s a concise guide to incorporating various types of media into HTML: video, audio, plugins, and YouTube videos.


  • Video You can embed a video in your using the <video> element. It supports several attributes for controls, autoplay, loop, and more.

<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>


 

  • The <audio> element is used, similar to the <video> element but for sound.

<audio controls>
<source src="audiofile.mp3" type="audio/mpeg">
<source src="audiofile.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>



  • Plugins can be embedded using the <object> element, which is a versatile tag for embedding multimedia (PDFs, Flash, etc.). However, plugins are becoming less common as modern  standards evolve.
<object data="file.pdf" type="application/pdf" width="600" height="400">
<p>It appears you don't have a PDF plugin for t
his browser. You can <a href="file.pdf">download PDF file.</a></p>
</object>



  • YouTube video is straightforward with the <iframe> element. This method is preferred for embedding videos from external sources like YouTube.

<iframe width="560" height="315" src="https://www.youtube.com/embed/tgbNymZ7vqY"
frameborder="0" allow="accelerometer; autoplay; encrypted-media;
gyroscope; picture-in-picture" allowfullscreen></iframe>

No comments:

Post a Comment