HTML5 Video Triggered by a graphic elswere on the page -


i trying figure out way have static image appear video when visitor first comes webpage. have graphic button if clicked trigger video play. graphic elswere on page not in or on top of video. so, guess looking how 2 things.

  1. play html5 video clicking graphic elswere on page

  2. when video played should swap out static graphic version active video version. ideally, once played static version replace video , reset play again.

any appreciated. thanks!

this should trick, make sure point 'video' , 'image' respective urls.

<script>     function dovideo()     {         var video = "myvideo.mp4";         document.getelementbyid("videoimgdiv").innerhtml = "<video autoplay onended=\"doimage()\"><source src=\"" + video + "\"\></video>";     }      function doimage()     {         var image = "http://us.123rf.com/400wm/400/400/podlesnova/podlesnova0906/podlesnova090600034/5117393-small-red-furry-kitten-with-blue-eyes.jpg";         document.getelementbyid("videoimgdiv").innerhtml = "<img onclick=\"dovideo()\" src=\"" + image + "\"/>";     }  </script>  <div id="videoimgdiv">   <img onclick="dovideo()"src="http://us.123rf.com/400wm/400/400/podlesnova/podlesnova0906/podlesnova090600034/5117393-small-red-furry-kitten-with-blue-eyes.jpg" /> </div> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -