Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasgriffin/9057466 to your computer and use it in GitHub Desktop.
Save thomasgriffin/9057466 to your computer and use it in GitHub Desktop.
Autoplay Vimeo videos on both load and transition.
<?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