开发者

Use function inside jQuery AnythingSlider plugin function outside plugin scope

I'm trying to integrate Chris Coyier's AnythingSlider (http://css-tricks.com/anythingslider-jquery-plugin/) with the YouTube API. When the video state is "play", I want to fire 'startStop(false)', and on video state 'pause' to fire 'startStop(true)'. But how can I use a function that's declared inside a plugin? I tried with something like $.anythingSlider.startStop() but to no avail. A simplified version of the function to check YouTube state change is shown below.

    function onytplayerStateChange(state) {
       switch(state) {
                case 1:  // playing
                  $("#jsfeedback").html("playing");
         $.anythingSlider(startStop(false));
                  break;
                case 2:  // paused
                  $("#jsfeedback").html("paused");
           $.anythingSlider(startStop(true));
                  break;
      }
  开发者_如何学编程 }

I'm not receiving any errors, and the Slider / Video work fine. But I cannot get the slider to stop on play.

Any thoughts? Many thanks.

EDIT: Fixed it myself, answer below


I fixed it myself, just added a public function to the end of the anythingSlider.js file:

    $.fn.startStopSlider=function(status) {
    if(status=="play") {
        base.startStop(true);
    }
    else if(status=="pause") {
        base.startStop(false);
    }
};

And just call it as:

    case 1:  // playing
    $('.anythingSlider').startStopSlider("pause");
      break;

etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜