I have this code
<video id="primorvid" onclick="this.paused ? this.play() : this.pause();" poster="http://primor.m-sites.co.il/wp-content/uploads/2016/08/Untitled-18.jpg" width="1903" height="564">
<source src="http://primor.m-sites.co.il/wp-content/uploads/2016/08/Primor-V.4-HD.mp4" type="video/mp4" />
</video>
the video works, it shows a poster image before i click the video, and the play/pause is working fine-
how do i proceed from here if i want the poster to reappear again after i pause the video?
Thank you very much David
Add this JS code:
Explanation:
Just getting the video and storing it in
vid, and declaring acurrentTimewhere we will store the time at which the video was paused.We add a click event listener to the video:
If the video's last state was playing (i.e. it is now paused), save the current time and reload it (this shows the poster and pauses the video):
Else, set the current time to what it was before and play again.
Another solution which wouldn't imply buffering the video again would be to set an overlaying element with your poster and show it when the video is paused, alongside an event listener.