Andys AnythingSlider playground

Add, remove, adjust any or all options so you can see how it works.

by Andrew Warren

HTML

<link rel="stylesheet" href="http://css-tricks.github.com/AnythingSlider/css/anythingslider.css">
<script src="http://css-tricks.github.com/AnythingSlider/js/jquery.anythingslider.js"></script>
<script src="http://css-tricks.github.com/AnythingSlider/js/jquery.easing.1.2.js"></script>
<script src="http://css-tricks.github.com/AnythingSlider/js/swfobject.js"></script>
<script src="http://css-tricks.github.com/AnythingSlider/js/jquery.anythingslider.fx.js"></script>
<!-- Add additional stylesheets here -->


<ul id="slider">

        <li class="panel6">
        <video width="320" height="240" controls="controls">
            <source src="http://nuhdisplay/tv/videos/antenatal%20class%20video%20advert%20v3_trimmed.mp4" type="video/mp4">
            Your browser does not support the video tag. But you could include an iframe/embeded video here.
        </video>
       
    </li>
    <li><img src="http://nuhdisplay/tv/inc/adminPages/imageManager/images/pgec/WelcomeCentre2_1476698696.png" alt="" /></li>
    <li><img src="http://placehold.it/300x200" alt="" /></li>
    <li><img src="http://placebear.com/300/200" alt="" /></li>
    <li><img src="http://lorempixel.com/300/200" alt="" /></li>
</ul>

CSS

/*** Set Slider dimensions here! Version 1.7+ ***/
/* added #slider li to make panels the same size in case "resizeContents" is false */
ul#slider, ul#slider li {
    width: 300px;
    height: 200px;
    list-style: none;
}

JavaScript

var playvid = function(slider) {
    var vid = slider.$currentPage.find('video');
    if (vid.length) {
        // autoplay
        vid[0].play();
    }
};

$('#slider').anythingSlider({
autoPlay            : true,
buildNavigation     : false, 
buildStartStop      : false,
buildArrows         : false,

    // Autoplay video in initial panel, if one exists
    onInitialized: function(e, slider) {
        playvid(slider);
    },
    // pause video when out of view
    onSlideInit: function(e, slider) {
        var vid = slider.$lastPage.find('video');
        if (vid.length && typeof(vid[0].pause) !== 'undefined') {
            vid[0].pause();
        }
    },
    // play video
    onSlideComplete: function(slider) {
        playvid(slider);
    },
    // pause slideshow if video is playing
    isVideoPlaying: function(slider) {
        var vid = slider.$currentPage.find('video');
        return (vid.length && typeof(vid[0].pause) !== 'undefined' && !vid[0].paused && !vid[0].ended);
    }

});