0
I have a page with a video that opens in a modal, I need it to be paused when the modal is hidden. I tried examples I found on other sites but it didn’t work.
I need to add some extra file to use the API control?
0
I have a page with a video that opens in a modal, I need it to be paused when the modal is hidden. I tried examples I found on other sites but it didn’t work.
I need to add some extra file to use the API control?
1
I don’t know how you’re closing your modal, but if you’re using .hide()
jQuery, you can do the following:
function pause_video(){
$('#youtube_iframe_id')[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
}
function hideCallBack() {
pause_video()
}
With the two functions added to your code, your video will pause when you close the modal using:
$('#modal_id').hide(hideCallBack);
Browser other questions tagged javascript jquery api youtube youtube-api
You are not signed in. Login or sign up in order to post.
How are you embedding the video ?
– Igor Mello