คุณสมบัติ ended ของ HTML DOM Video ใช้สำหรับคืนค่า boolean (true/false) ที่บ่งชี้ว่าวิดีโอถึงจุดสิ้นสุดแล้วหรือไม่
ไวยากรณ์ (Syntax)
การคืนค่า Boolean
mediaObject.ended
ตัวอย่างการใช้งาน
ตัวอย่างต่อไปนี้แสดงการใช้งานคุณสมบัติ HTML DOM Video ended:
<!DOCTYPE html> <html> <head> <title>HTML DOM Video ended</title> <style> * { padding: 2px; margin:5px; } form { width:70%; margin: 0 auto; text-align: center; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>HTML-DOM-Video-ended</legend> <video id="demo" width="320" controls><source src="https://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br> <input type="button" onclick="getTrackDetails()" value="How many seconds before the video ends?"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var demo = document.getElementById("demo"); function getTrackDetails() { if(demo.ended === false) divDisplay.textContent = 'Video ends in: '+(demo.duration - demo.currentTime)+' seconds'; } </script> </body> </html>
ผลลัพธ์
ก่อนคลิกปุ่ม 'How many seconds before the video ends?':

หลังคลิกปุ่ม 'How many seconds before the video ends?':
