Slider Revolution WP
09.27.2016
A video can now be played easily by adding a button along with Layer Actions.
Normally when a video is added to a slider, either the video itself is visible, or the video’s “poster” would show. But if you wanted to hide the video initially, and then add a discrete “Play Video” button to the slide, which would then show and play the hidden video, this can be achieved with custom classes, CSS, and using the slider’s API.
1 2 3 4 |
.rev_slider .my-video {display: none} .rev_slider .play-button {cursor: pointer} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
jQuery('body').on('click', '.play-button', function() { var slide = jQuery(this).closest('li'), vid = slide.find('.my-video').show(); vid.find('video')[0].play(); }); // change the "revapi1" parts to whatever api name is used for your slider revapi1.on('revolution.slide.onchange', function() { revapi1.find('.my-video').hide(); }); |
In the above JavaScript, you’ll notice a “revapi1” part in two places. This will need to be altered to represent the api name for your particular slider. To find this name, directly above the “Custom CSS/JavaScript” section, click the “API Functions” section, and you’ll see the “revapi” name for your slider: