Play a video just by clicking on it

Hi to everyone!

I’m new to Hype and I have this issue… I want to be able to play and pause a video without any buttons or commands. I want the video to be played just by clicking on it, then paused the same way. I guess I’ll need a little bit of Java.

I have to add that there’s gonna be more than one video in the same scene.

Here the file in question.

video_java.hype.zip (1.8 MB)

Thanks!

set this onclick or touchstart for every hypevideoelement

    var dataPlay = element.getAttribute("data-play");
    if(dataPlay === null || dataPlay === '1'){ 
    element.setAttribute("data-play", '0');
    element.play();
    }else{
    element.setAttribute("data-play", '1');
    element.pause();    
    }

though not tested, but should work …

1 Like

Thank you so much! That is working like a charm. It feels a little bit like magic :wink:.

Result : www.martineaulachance.com