html5-video event timeupdate在Chrome浏览器上触发两次。为什么html5-video event timeupdate在Chrome浏览器上触发两次?
重现步骤:
- 运行代码
<!DOCTYPE html>
<html lang="en">
<head>
\t <script
src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
crossorigin="anonymous"></script>
\t </head>
\t <body>
\t \t <video id="video">
<source src=http://techslides.com/demos/sample-videos/small.mp4 type=video/mp4>
</video>
\t \t <button id="button">Update time</button>
\t \t <script>
\t \t \t $(document).ready(function() {
\t \t \t \t var vid = document.getElementById("video")
\t \t \t \t vid.addEventListener("timeupdate", timeUpdate, false);
\t \t \t \t
\t \t \t \t $("#button").on("click", buttonClick);
\t \t \t \t
\t \t \t \t function timeUpdate(e){
\t \t \t \t \t console.log("timeUpdate");
\t \t \t \t }
\t \t \t \t
\t \t \t \t function buttonClick(e){
\t \t \t \t \t console.log("buttonClick"); \t \t \t \t \t
\t \t \t \t \t vid.currentTime = 1;
\t \t \t \t }
\t \t \t }); \t \t \t
\t \t </script>
\t </body>
</html>
- 点击按钮
- 检查结果(buttonClick x 1,timeUpdate x 2) 个
任何想法?))
你检查了这个stackoverflow问题的答案吗? http://stackoverflow.com/questions/19511253/call-twice-timeupdate – user1731468
是的,我有,但答案没有帮助。 –