Copy link to clipboard
Copied
I'm having issues getting an mp4 to play when I click a button. To simplify troubleshooting I started a new project with a video component and a button component and followed the steps on this page: Components in Animate
I followed the steps, have everything on frame one, and I'm using the below code. This is taken directly from the example page. The problem is that the video doesn't play when I click the button. It will play if I check "Autoplay" or make the controls visible and use those. I'm trying to figure this out before I integrate it into my actual project and make the video play with those buttons.
For clarity, Animate assigned the instance names "movieClip_2" to the button and "movieClip_3" to my video.
if (!this.movieClip_2_click_cbk) {
function movieClip_2_click(evt) {
console.log("Button clicked");
this.movieClip_3.on("added", function () {
$("#movieClip_3")[0].play();
}, this, true);
}
$("#dom_overlay_container").on("click", "#movieClip_2", movieClip_2_click.bind(this));
this.movieClip_2_click_cbk = true;
}
Copy link to clipboard
Copied
I ended up using the Code Wizard which produced a significantly simpler output, but more importantly, it works!
this.btn1.on('click', function () {
$('#v1')[0].play();
});
That being said, if someone runs across this and could explain to me why the nested snippets didn't work I'd appreciate it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now