CSS-Tricks / AnythingSlider

A jQuery Slider plugin for anything.
http://css-tricks.github.io/AnythingSlider/
GNU Lesser General Public License v3.0
1.15k stars 380 forks source link

html5 video slider issue #650

Closed cmanish049 closed 8 years ago

cmanish049 commented 8 years ago

I am using anything slider with html5 videos and images. I have customized it to play first slider video on page load After it finishes playing next slide is shown. And it works fine in my test work with only html but when i implement it in my php code it doesnot work why. Please can anyone help

    // Set up Sliders
    // **************
    $(function(){
      var playvid = function(slider) {

        var vid = slider.$currentPage.find('video');

        if (vid.length) {

          // autoplay
          vid[0].currentTime = 0;
          vid[0].play();

        }

      };
      $('#slider1').anythingSlider({
        autoplay  : true, 
        theme     : 'metallic',
        // easing          : 'easeInOutBack',
        easing    : 'linear',
        // autoPlayDelayed     : true,
        // delay     : <?php echo BANNER_DURATION;?>,
        // animationTime       : 500,
         // expand: true,
         //aspectRatio: true,

        onSlideComplete : function(slider){
          // alert('Welcome to Slide #' + slider.currentPage);
        },
        onInitialized: function(e, slider) {

          playvid(slider);

        },
        onSlideInit: function(e, slider) {

          var vid = slider.$lastPage.find('video');

          if (vid.length && typeof(vid[0].pause) !== 'undefined') {

          vid[0].pause();

          }

        },
        onSlideComplete: function(slider) {

          playvid(slider);

        },
        isVideoPlaying: function(slider) {

          var vid = slider.$currentPage.find('video');

          return (vid.length && typeof(vid[0].pause) !== 'undefined' && !vid[0].paused && !vid[0].ended);

        },
      });

    });

This is my code

Mottie commented 8 years ago

Hi @cmanish049!

Everything is the code appears to be correct, so I'm not sure why it isn't working inside the php code. Are you seeing any errors in the console? What does the rendered PHP look like?

cmanish049 commented 8 years ago

Thanks for ur response, May be there was error in my php code. I changed my code with the one i have kept backup earlier and it worked.

thanks once again