onplaying event
onplaying Event
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <p>该实例演示了如何向 video 元素添加 "onplaying" 事件。</p> <p>尝试播放,暂停然后再次播放视频。</p> <video controls onplaying="myFunction()"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> 您的浏览器不支持 HTML5 video。 </video> <script> function myFunction() { alert("视频正在播放"); } </script> </body> </html>
Run Instance»
Click "Run Instance" button to view an online instance
More examples are included at the bottom of this article.
Definition and Usage
The onplaying event is triggered when the video/audio (audio/video) is paused or ready to restart playback after buffering.
Browser support
The number in the table indicates the version number of the first browser that supports the event.
Syntax
HTML:
<element
onplaying="myScript">Try it
In JavaScript:
##object.onplaying=function(){ myScript};Try it
##object
Note: .addEventListener("playing ", myScript);Try it
Internet Explorer 8 and earlier IE versions do not support the addEventListener() method. Technical details
No | |
---|---|
No | |
Event | ##Supported HTML tags: |
##More examples
Examples
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <p>该实例演示了如何向 audio 元素添加 "onplaying" 事件。</p> <p>尝试播放,暂停然后再次播放视频。</p> <audio controls onplaying="myFunction()"> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> 您的浏览器不支持 HTML5 video。 </audio> <script> function myFunction() { alert("视频正在播放"); } </script> </body> </html>##