javascript - redirect to image after video ends -


I am working on the site, as soon as we make a video as we enter the site. The problem is that it just ends and I want to change it with an image after it's finished, is there any way I can redirect it to the same container?

  & lt; Video id = "video_background" preload = "auto" volume = "5" autoplay = "1" & gt; & Lt ;! - or turn on loop = "loop" - & gt; & Lt; Source src = "video / trailer.wbm" type = "video / webm" & gt; & Lt; Source src = "video / trailer.mp4" type = "video / mp34" & gt; & Lt; Source src = "video / trailer.ogg" type = "video / og ogve" & gt; & Lt; / Video & gt;   

To wrap your video tag in a div Need container Try the following code:

CSS:

  #wrapper {width: 640px; Height: 360px; Background: # 000; } #image_background {display: none; }   

HTML:

  & lt; Div id = "wrapper" & gt; & Lt; Video id = "video_background" preload = "auto" volume = "5" autoplay = "1" width = "100%" height = "100%" & gt; & Lt; Source src = "video / trailer.wbm" type = "video / webm" /> & Lt; Source src = "video / trailer.mp4" type = "video / mp34" /> & Lt; source src = "video / trailer.ogg" type = "video / og ogew" /> & Lt; / Video & gt; & Lt; img id = "image_background" src = "yourImage.jpg" width = "100%" height = "100%" /> & Lt; / Div & gt;   

JS:

  var video = document.getElementById ('video_background'); Var cover = document. GetElementById ('wrapper'); Var image = document.getElementById ('image_background'); video.addEventListener ('end', function () {video.style.display = 'none'; image.style.display = 'inline';}, false);   

Edit: How can I fade in smooth transition or something else?

Use jQuery for it because it is built with such functionality.

  & lt; Script src = "http://code.jquery.com/jquery-1.10.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; var video = $ ('# video_background'); var image = $ ('# image_background'); Video .on ('expired', function () {$ (this). Fadeaut ('200', function) (// $) refers to the video image. FadeIn ('200');})}} ); & Lt; / Script & gt;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -