diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index fbb41bbdf..30ece2be5 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1332,12 +1332,26 @@ function qmnInitPagination(quiz_id) { function qsmPauseVideo( quiz_id, btn ) { let video_sections = jQuery(btn).closest(`.qsm-quiz-container-${quiz_id}.qmn_quiz_container`).find('video:visible'); + let iframeVideos = jQuery(btn).closest(`.qsm-quiz-container-${quiz_id}.qmn_quiz_container`).find('iframe:visible'); + + iframeVideos.each(function() { + let src = this.src; + const vimeoDomainPattern = /^(?:https?:\/\/)?(?:www\.)?(player\.)?vimeo\.com\/.*$/; + if ( vimeoDomainPattern.test(src) ) { + const vimeoPlayer = new Vimeo.Player(this); + vimeoPlayer.pause(); + } else { + jQuery(this).attr('src', ''); + jQuery(this).attr('src', src); + } + }); video_sections.each(function() { if (!this.paused) { this.pause(); } }); } + function qmnSocialShare(network, mlw_qmn_social_text, mlw_qmn_title, facebook_id, share_url) { var sTop = window.screen.height / 2 - (218); var sLeft = window.screen.width / 2 - (313); diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index d1400366c..a62006c3e 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -889,6 +889,7 @@ public function display_quiz( $options, $quiz_data, $question_amount, $shortcode if ( ! $qmn_allowed_visit ) { return; } + wp_enqueue_script('vimeo-iframe-api', 'https://player.vimeo.com/api/player.js'); wp_enqueue_script( 'json2' ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-core' );