Last active
August 29, 2015 13:56
-
-
Save thomasgriffin/9057466 to your computer and use it in GitHub Desktop.
Autoplay Vimeo videos on both load and transition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'soliloquy_api_on_load', 'tgm_soliloquy_autoplay_vimeo_on_load' ); | |
function tgm_soliloquy_autoplay_vimeo_on_load( $data ) { | |
ob_start(); | |
?> | |
var slide_video = soliloquy_<?php echo $data['id']; ?>.find('.soliloquy-item:not(.soliloquy-clone):eq(' + currentIndex + ') .soliloquy-video-icon'); | |
if ( slide_video.length > 0 ) { | |
var video_type = slide_video.data('soliloquy-video-type'); | |
if ( 'vimeo' == video_type ) { | |
var video_id = slide_video.data('soliloquy-video-id'); | |
if ( ! soliloquy_vimeo[video_id] ) { | |
setTimeout(function(){ | |
slide_video.trigger('click'); | |
}, 500); | |
} | |
} | |
} | |
<?php | |
echo ob_get_clean(); | |
} | |
add_action( 'soliloquy_api_after_transition', 'tgm_soliloquy_autoplay_vimeo_on_transition' ); | |
function tgm_soliloquy_autoplay_vimeo_on_transition( $data ) { | |
ob_start(); | |
?> | |
var slide_video = $(element).find('.soliloquy-video-icon'); | |
if ( slide_video.length > 0 ) { | |
var video_type = slide_video.data('soliloquy-video-type'); | |
if ( 'vimeo' == video_type ) { | |
var video_id = slide_video.data('soliloquy-video-id'); | |
if ( ! soliloquy_vimeo[video_id] ) { | |
setTimeout(function(){ | |
slide_video.trigger('click'); | |
}, 500); | |
} | |
} | |
} | |
<?php | |
echo ob_get_clean(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment