代码示例:(标识:event_onplay_html)
<!DOCTYPE html>
<html>
<body>

<p>本例演示如何将 "onplay" 事件分配给 video 元素。</p>

<p>Press play.</p>

<video controls onplay="myFunction()">
  <source src="/static/demo/video/shanghai.mp4" type="video/mp4">
  Your browser does not support HTML5 video.
</video>


<script>
function myFunction() {
  alert("The video has started to play");
}
</script>

</body>
</html>
运行结果: