Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin thomasgriffin/gist:9057466
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.