Anki Forums

Click button to play a video

I am currently use this script,

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

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?

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.

1 Like

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