Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How do you stop AnythingSlider via code?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29428
    oneworld95
    Member

    Hi. I’m using the great AnythingSlider carousel control and have video on various "slides." When the user clicks the Play button on the Flowplayer Flash player to start the video, I want to stop the AnythingSlider; I’m using the HTML5 video tag, and was able to write an event handler for the onPlaying event. But this event handler only toggles the start/stop state; in other words, if the AnythingSlider is started, it will stop it, and if it’s stopped, it’ll start it. Here’s the code for the function:

    Code:
    function stopSlider(){
    $(“div.anythingSlider a#start-stop”).trigger(“click”);
    }

    Is there a way to actually tell the AnythingSlider to stop?

    Thanks, by the way, for this great component. Our new web site design will use it and everyone is asking how that control was done — "Is it Flash?" And I tell them nope, it’s JavaScript. You’re making a lot of web developers look great :D

    #78254
    oneworld95
    Member

    This is not the most elegant solution, but it works:

    Code:
    function stopSlider(){
    while (1 == 1){
    $(“div.anythingSlider a#start-stop”).trigger(“click”);
    if ($(“div.anythingSlider a#start-stop”).html().indexOf(“Go”) != -1)
    break;
    }
    }

    Trigger the "click" on the "start-stop" element, checking after each click to see if the html of the element contains the word "Go". If it does, break out of loop. Even though the AnythingSlider code has a line saying "Pass startStop(false) to stop and startStop(true) to play", I couldn’t figure out how to call that function regardless of what I tried. Now this solution works and I’m happy :D

    #78304
    oneworld95
    Member

    Hi, Darfuria. It depends on which SWF player you’re using. There is documentation on how to use JavaScript to manipulate the Flash player. For YouTube embedded videos, you’re using their player and so check out their JavaScript API here: http://code.google.com/apis/youtube/js_api_reference.html; from their documentation:

    Quote:
    onStateChange
    This event is fired whenever the player’s state changes. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5). When the SWF is first loaded it will broadcast an unstarted (-1) event. When the video is cued and ready to play it will broadcast a video cued event (5).

    Inside the onStateChange listener, you’d check to see if it’s playing (1); if so, you’d call the stopSlider() function.

    #78310
    oneworld95
    Member

    That I don’t know. You can post a question to their developer forum on this: http://groups.google.com/group/youtube-api

    #78312
    oneworld95
    Member

    Try posting your question to http://stackoverflow.com. I’ve had great luck with them and they’re usually very quick at responding. Good luck :)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.