Docs/HTML/Audio & Video

HTML Audio & Video

HTML5 menyediakan elemen native untuk memutar audio dan video tanpa plugin.

<video> Attributes

  • src — URL file video
  • controls — tampilkan kontrol play/pause/volume
  • autoplay — putar otomatis
  • muted — mulai tanpa suara
  • loop — putar berulang
  • poster — gambar thumbnail sebelum diputar
  • preload — auto/metadata/none

<audio> Attributes

Sama seperti video, minus poster dan dimensi visual.

Format yang Didukung

  • Video: MP4 (H.264), WebM, Ogg
  • Audio: MP3, WAV, Ogg, AAC
index.html
Try It →
<h3>Video Player</h3>
<video width="100%" controls poster="https://picsum.photos/400/200">
  <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  Browser kamu tidak support tag video.
</video>

<h3>Audio Player</h3>
<audio controls>
  <source src="https://www.w3schools.com/html/horse.ogg" type="audio/ogg">
  <source src="https://www.w3schools.com/html/horse.mp3" type="audio/mpeg">
  Browser kamu tidak support tag audio.
</audio>

<h3>Video GIF-like (autoplay, muted, loop)</h3>
<video width="200" autoplay muted loop>
  <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
</video>