9

I am using Cincopa to embed my video into my website. The page that it is embedded in is hidden and navigation is removed. So I would like everyone to be redirected to the home page once the video is finished.

Here is my code:

<div id="cp_widget_55a42f1b-6e51-4738-87f9-eaf52dc6a826">...</div>
<script type="text/javascript">
    var cpo = [];
    cpo["_object"] = "cp_widget_55a42f1b-6e51-4738-87f9-eaf52dc6a826";
    cpo["_fid"] = "AsBAj2M3MQOr";
    var _cpmp = _cpmp || [];
    _cpmp.push(cpo);
    (function() {
        var cp = document.createElement("script");
        cp.type = "text/javascript";
        cp.async = true;
        cp.src = "//www.cincopa.com/media-platform/runtime/libasync.js";
        var c = document.getElementsByTagName("script")[0];
        c.parentNode.insertBefore(cp, c);
    })();
</script>
<noscript>Powered by Cincopa <a href='http://www.cincopa.com/video-hosting'>Video Hosting for Business</a> solution.<span>Test</span><span>bitrate</span><span> 39961 kb/s</span><span>height</span><span> 1080</span><span>duration</span><span> 00:02:35.31</span><span>lat</span>:<span> +33.2269</span><span>long</span>:<span> 21-96.93</span><span>fps</span><span> 59.94</span><span>width</span><span> 1920</span><span>originaldate</span><span> 2015-06-06 19:08:58</span>
</noscript>
3

4 Answers 4

8

Cincopa embeds a video HTML tag, you have to add an event as explained here

Well, right now I'm not quite in the mood to make a complete test, so I'll just suggest a workaround which you will need to adapt.

In order to give you the exact code, I need to know:

  1. What CMS are you using?
  2. Can you add an id or a class to your video tag with cincopa?
  3. Are you including jQuery?

Then you'll have to add this lines in the bottom of your script:

//Wait until the page is entirely loaded, and so you can access the rendered video tag (you'll need jQuery)
$( document ).ready(function() {
    
    function goHomeYouAreDrunk(e) {
        window.location.href = "http://url.to.your.home.page";
    }
    //I'm supposing that your video is the sole video tag in your page, if it's not, you'll have to get it by its id or class
    document.find('video').addEventListener('ended',goHomeYouArDrunk,false);
});
7
  • Okay thank you. I guess maybe I am not quite understanding how to exactly do this or even where this needs to be placed in the code. Could you perhaps help me out here. Aug 13, 2015 at 21:17
  • I'm not at home, but I'll try to edit the answer as soon as I come back Aug 13, 2015 at 21:22
  • I would greatly appreciate your help. Thank you! Aug 13, 2015 at 22:19
  • Okay, it's not in my top ten answers, but at least this should point you in the right direction. I'll complete it tomorrow when I'm sober... Aug 13, 2015 at 23:02
  • Luis, I appreciate your help. I am using WIX and I can edit the CSS in Cincopa. I am not using jquery that I am aware of. CSS code is to long to paste in here. Aug 14, 2015 at 0:12
1

Normally, that would be via an event listener on the <audio> or <video> element.

How to add Event Listeners | W3Schools : https://www.w3schools.com/Jsref/met_element_addeventlistener.asp

But a way I'd do it with Javascript just to be sure is:

// The interval clocks every .1 second(s).
setInterval(function() {
    // If the element's current playback time is the playback duration (has reached the end).
    if (audioElement.currentTime == audioElement.duration)
        doSomething()
}, 100)

Although if you are wary about performance and don't want to use a setInterval() function, then stick with adding an event to the element.

By the way, to re-direct to another page, use the Javascript function location.assign("https://www.example.com.").

1

This code has been tested in https://www.cincopa.com/:

document.getElementById("video_iframe_id_in_your_page")
    .contentWindow
    .document.getElementsByTagName("video")[0]
    .addEventListener("ended", function(args){
        window.open("/", "_top");
    });

wish can help you.

0

You can redirect to the home page by setting window.location="/"

I'm not sure how you're checking if the video has ended, you can add a listener like this.

Upon completion, you can call a handler function to redirect the user to the homepage.

document.getElementById('myVideo').addEventListener('ended',redirectToHomePage,false);

redirectToHomePage(){
   window.location = "/";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.