Jeff Miller提出了一个问题:Detect if HTML5 Video element is playing,或许与您遇到的问题类似。
回答者Diode给出了该问题的处理方式:
Note : This answer was given in 2011. Please check the updated documentation on HTML5 video before proceeding.
If you just want to know whether the video is paused, use the flag stream.paused.
There is no property for video element for getting the playing status. But there is one event "playing" which will be triggered when it starts to play. Event "ended" is triggered when it stops playing.
So the solution is
decalre one variable videoStatus
add event handlers for different events of video
update videoStatus using the event handlers
use videoStatus to identify the status of the video
This page will give you a better idea about video events. Play the video on this page and see how events are triggered.
http://www.w3.org/2010/05/video/mediaevents.html
希望本文对你有帮助,欢迎支持JavaScript中文网