Skip to content

Commit

Permalink
Fixed not pausing video on click next or previous btn click
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-pranav committed Dec 26, 2023
1 parent e3744dd commit f95847a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit f95847a

Please sign in to comment.