HTML <วิดีโอ>แท็ก
ตัวอย่าง
เล่นวิดีโอ:
<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>
ความหมายและการใช้งาน
แท็ ก<video>
นี้ใช้เพื่อฝังเนื้อหาวิดีโอในเอกสาร เช่น คลิปภาพยนตร์หรือสตรีมวิดีโออื่นๆ
<video>
แท็กนี้มีแท็กตั้งแต่หนึ่งแท็กขึ้น
ไป<source>
ที่มีแหล่งที่มาของวิดีโอต่างกัน เบราว์เซอร์จะเลือกแหล่งที่มาแรกที่รองรับ
ข้อความระหว่าง แท็ก <video>
และ</video>
จะแสดงในเบราว์เซอร์ที่ไม่สนับสนุนองค์ประกอบ <video> เท่านั้น
มีรูปแบบวิดีโอที่รองรับสามรูปแบบใน HTML: MP4, WebM และ OGG
Browser | MP4 | WebM | Ogg |
---|---|---|---|
Edge | YES | YES | YES |
Chrome | YES | YES | YES |
Firefox | YES | YES | YES |
Safari | YES | YES | NO |
Opera | YES | YES | YES |
เคล็ดลับและหมายเหตุ
เคล็ดลับ:สำหรับไฟล์เสียง ให้ดูที่แท็ก
<audio>
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนองค์ประกอบอย่างสมบูรณ์
Element | |||||
---|---|---|---|---|---|
<video> | 4.0 | 9.0 | 3.5 | 3.1 | 11.5 |
คุณสมบัติเสริม
Attribute | Value | Description |
---|---|---|
autoplay | autoplay | Specifies that the video will start playing as soon as it is ready |
controls | controls | Specifies that video controls should be displayed (such as a play/pause button etc). |
height | pixels | Sets the height of the video player |
loop | loop | Specifies that the video will start over again, every time it is finished |
muted | muted | Specifies that the audio output of the video should be muted |
poster | URL | Specifies an image to be shown while the video is downloading, or until the user hits the play button |
preload | auto metadata none |
Specifies if and how the author thinks the video should be loaded when the page loads |
src | URL | Specifies the URL of the video file |
width | pixels | Sets the width of the video player |
คุณสมบัติสากล
แท็ ก<video>
ยังสนับสนุน Global Attributes ในHTML
คุณสมบัติของเหตุการณ์
แท็ ก<video>
ยังสนับสนุนแอตทริบิวต์เหตุการณ์ใน HTML
หน้าที่เกี่ยวข้อง
การอ้างอิง HTML DOM: การอ้างอิง DOM เสียง/วิดีโอ HTML
การตั้งค่า CSS เริ่มต้น
ไม่มี.