Forum Discussion

PhilMayor-b4ca0's avatar
PhilMayor-b4ca0
Community Member
8 months ago

Play button

Is there a way to detect if the play button has been pressed on a video?  I have a play/pause button on the slide as well and want to keep them both in sync

  • Probably the best way is to use the slide timeline and controls for both. Start the video when the slide timeline starts, and do not allow the video to be controlled independently of the slide. Do that by not showing video controls, and covering the video with a transparent shape (filled with 98% transparency).

    That ties the video to the slide timeline, unless of course, it is a web object.

  • Thanks, Walt; that doesn't work for the slide, unfortunately; I had already suggested that.

    I don't think you need 98% transparency anymore 100% should work now.

    I am going to have a dig into some javascript to solve it.

    • PhilMayor's avatar
      PhilMayor
      Super Hero

      This one looks great as well, I think Nedim’s solution is probably best to work with what I have but will keep this in mind for future projects. Thanks. 

  • Nedim's avatar
    Nedim
    Community Member

    Hi Phil,

    I use a javascript video "ontimeupdate" function to detect if video is playing or not. Basically, it detects when either play or pause button has been pressed. Not sure if it's exactly what are you looking for. Check my short video and let me know if you need a code. 

  • Hi Nedim thanks that looks like a perfect solution could you post the code? Thank you

  • Nedim's avatar
    Nedim
    Community Member

    Here you go Phil:

    let video = document.getElementsByTagName('video')[0];

    video.ontimeupdate = function() { 
        
        if (video.playing) {
            GetPlayer().SetVar('isVideoPlaying', true);
        } else {
            GetPlayer().SetVar('isVideoPlaying', false);
        }
        
    };

    I also attached the storyline file for reference.