Click button to play a video

I am currently use this script,


<div id="ID" style="display:none">
{{video}}
</div>
<button class="button" type="button"  onclick="
        if
            (document.getElementById('ID') .style.display=='none')
            {document.getElementById('ID') .style.display=''}
        else
            {document.getElementById('ID') .style.display='none'}">
    video
</button>

but the problem with it is that the button doesn’t control the sound, which means that the video is automatically playing, only I can’t see it until I click on the button. Anyone knows a workaround?

1 Like

All the button does is control the display of the div in which the video is contained.

I’ve never tried embedding videos in my cards, so dunno how the autoplay thing works, but you’ll probably need to figure out a way to stop the video from playing, and then add the play method to the onclick function of the button.

2 Likes

One alternative, if your cards do not have other audio files, would be to turn off autoplay in the deck options - it will stop the videos from playing automatically.

1 Like