Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Autoplay Wistia videos on load and transition.
<?php
add_action( 'soliloquy_api_on_load', 'tgm_soliloquy_autoplay_wistia_on_load' );
function tgm_soliloquy_autoplay_wistia_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 ( 'wistia' == video_type ) {
var video_id = slide_video.data('soliloquy-video-id');
if ( ! soliloquy_wistia[video_id] ) {
setTimeout(function(){
slide_video.trigger('click');
}, 500);
}
}
}
<?php
echo ob_get_clean();
}
add_action( 'soliloquy_api_after_transition', 'tgm_soliloquy_autoplay_wistia_on_transition' );
function tgm_soliloquy_autoplay_wistia_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 ( 'wistia' == video_type ) {
var video_id = slide_video.data('soliloquy-video-id');
if ( ! soliloquy_wistia[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.