English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The play() method allows media files to attempt to play(video/audio) and returns a Promise
HTML Audio/Video DOM Reference Manual
Video with Play and Pause Buttons:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Video play() Method Usage-Basic Tutorial(oldtoolbag.com)</<title> </<head> <body> <button onclick="playVid()" type="button">Play Video</button> <button onclick="pauseVid()" type="button">Pause Video</button> <br> <video id="video"1"> <source src="movie.mp"4"type="video"/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> var myVideo=document.getElementById("video",1"); function playVid() { myVideo.play(); } function pauseVid() { myVideo.pause(); } </script> </body> </html>Test to see ‹/›
The play() method starts playing the current audio or video.
IEFirefoxOperaChromeSafari
All major browsers support the play() method.
Note:Internet Explorer 8 and earlier versions do not support this method.
audio|video.play()