make html5 video go to first frame when it ends?

前端 未结 2 1103
轮回少年
轮回少年 2020-12-17 03:31

I have a simple video html5 tag, bound to an \"ended\" event:

$(\'#video\').show().trigger(\"play\").bind(\'ended\', function () { 
//code
}
<
相关标签:
2条回答
  • 2020-12-17 03:49

    This goes in the head:

    <script>
    function Reset() { document.getElementById('MyVideo').load(); }
    </script>
    

    This goes in the video tag:

    <video ID="MyVideo" onended="Reset()" [plus your other parameters] >
    
    0 讨论(0)
  • 2020-12-17 03:57

    You can use something like

    $('#video').show().trigger("play").bind('ended', function () { 
        this.currentTime = 0;
    }
    

    You can only set the currentTime if the loadedmetadata event has passed.

    0 讨论(0)
提交回复
热议问题