Home › Forums › JavaScript › How do you stop AnythingSlider via code?
- This topic is empty.
-
AuthorPosts
-
June 20, 2010 at 3:04 pm #29428
oneworld95
MemberHi. 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
June 20, 2010 at 6:51 pm #78254oneworld95
MemberThis 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
June 21, 2010 at 2:33 pm #78304oneworld95
MemberHi, 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.
June 21, 2010 at 3:31 pm #78310oneworld95
MemberThat I don’t know. You can post a question to their developer forum on this: http://groups.google.com/group/youtube-api
June 21, 2010 at 3:51 pm #78312oneworld95
MemberTry posting your question to http://stackoverflow.com. I’ve had great luck with them and they’re usually very quick at responding. Good luck :)
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.