Detect video ended

stp atric ks.fin alsite .com

$(".video-advanced").on("click", ".fsMediaContainer", function() {
      if(!$(this).hasClass("once")) {
        $(this).addClass("once");
        $('<div class="video-lightbox"><button class="fsCloseVideoBtn"></button></div>').prependTo(".video-advanced");
        $(this).parents(".video-advanced").addClass("playing");
        $(this).appendTo($(this).parents(".video-advanced").find(".video-lightbox"));
        $(this).find("video").get(0).play();

        $(this).find('video').get(0).onended=function(e) {
          alert("asdf");
        };
      }

Orange section…click the video.

I’m getting a console error

undefined:1 Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().

I’m not getting much out of Google on my searches. Can someone explain what the issue is?

I tried moving that onended function into a set interval which tried to eventually find the lightbox element video once made, and then run the onended, but I kept getting console errors there…so I went this approach.How should I handle this? The lightbox is made dynamically and the video is appended there and plays. On video finishing, I plan on doing some stuff.

So I have it working but I’m still getting console errors. Is this something I should be worried about? Page is in post # 1

$('body').on('DOMNodeInserted', '.video-lightbox', function () {
      var checkVideo=setInterval(function() {
        if($(".video-advanced .video-lightbox video").length) {
          console.log("final");
          clearInterval(checkVideo);
          $(".video-advanced .video-lightbox video").get(0).onended=function(e) {
            $(".video-advanced").find(".fsMediaContainer").appendTo($(".video-advanced").find(".fsMedia.fsPlayer > .fsElementContent"));
            $(".video-lightbox").remove();
            $(".video-advanced").removeClass("playing");
          };
        }
        else {
        console.log("run");
        }
      },500);
    });
    $(".video-advanced").on("click", ".fsMediaContainer", function() {
      if(!$(this).hasClass("once")) {
        $(this).addClass("once");
        $('<div class="video-lightbox"><button class="fsCloseVideoBtn"></button></div>').prependTo(".video-advanced");
        $(this).parents(".video-advanced").addClass("playing");
        $(this).appendTo($(this).parents(".video-advanced").find(".video-lightbox"));
        $(this).find("video").get(0).play();
      }
    });

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.