How to implement a listener in a video?

0

Well, I have a button and when I click it, it will call a function that opens a page with a fullscreen video with autoplay="true". IT HAPPENS THAT, after finishing the video I need to redirect the user to another html page. Can someone tell me a way to implement this script? I think it would be some kind of listener, but I have no idea.

    
asked by anonymous 25.10.2017 / 16:49

1 answer

0

There is a property of HTML 5 videos that can detect whether the video is gone or not.

To heal your doubt I think that few lines of code are necessary

 //caso o vídeo tenha acabado o retorno é true, caso não será false
   document.getElementById('myVideo').addEventListener('ended',myHandler,false);

    function myHandler(e) {
        window.location.href = "http://pt.stackoverflow.com";    
    }

Useful Link

Detect video end

    
25.10.2017 / 16:55