Stop sliding when play Vimeo or Youtube video in the slider

允我心安 提交于 2019-12-11 09:23:48

问题


Which the best way to have a script that I can stop the slider slide when I play Vimeo or Youtube video in the slider?

very much appreciated with you all help.

jQuery(document).ready(function(){
jQuery('#gdl-custom-slider ul').cycle({ 
    before:     before_transition,
    after:      after_transition,
    fx:         'fade',
    pager:      '#custom-slider-nav',

    speed:      CUSTOM.speed, 
    timeout:    CUSTOM.timeout 
});



function before_transition(curr, next, opts, fwd){
    jQuery(next).find('.custom-slider-title').css({'top':'15px','opacity':'0'});
    jQuery(next).find('.custom-slider-caption').css({'top':'15px','opacity':'0'});
}

function after_transition(curr, next, opts, fwd){
    jQuery(this).find('.custom-slider-title').delay(100).animate({'top':'0px','opacity':'1'}, 200);
    jQuery(this).find('.custom-slider-caption').delay(400).animate({'top':'0px','opacity':'1'}, 200);
}
});

回答1:


You have to use Vimeo and Youtube player APIs.

Vimeo

To turn the API on, add api=1 to the URL of the iframe, like this:

http://player.vimeo.com/video/VIDEO_ID?api=1 

JSFiddle

More information here.


Youtube

To turn the API on, add ?version=3&enablejsapi=1 to the iframe url.

http://www.youtube.com/v/VIDEO_ID?version=3&enablejsapi=1

DEMO

See more information on the documentation pages.


When clicking "Start" button you will stop the slider, and when you will click the "Start" button you will start the slider.



来源:https://stackoverflow.com/questions/17133994/stop-sliding-when-play-vimeo-or-youtube-video-in-the-slider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!