treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Anythingslider + Longtail + Event Listeners

  • I've implemented the Fabulous AnythingSlider with images and video (using the longtail flv player).

    Problem: When the user plays the video, the slideshow doesn't know this has happened, so the slideshow keeps cycling while the video runs. So you have the slideshow running - and user can hear the audio but the video has cycled off.

    I'm trying to figure out an event-listener that will look and see when the LONGTAIL player is in PLAYING state and signals to the AnythingSlider that it needs to STOP.

    Here's what I've got so far ... which is probably not worth much as it doesn't work!!


    // Fires when the VIDEO player is succesfully initialized and drawn on the page
    function playerReady(obj) {
    player = document.getElementById(obj['vucastvid']);
    // This line adds the listener.
    player.addModelListener(\"STATE\",\"stateHandler\");
    };
    // This function is called every time the listener is fired
    function stateHandler(obj) {
    // if the VIDEO state is changed to \"PLAYING\"
    if(obj.newstate == \"PLAYING\") {
    // make the SLIDESHOW STOP
    $('.AnythingSlider').base({'startStop':'false'});
    }else {
    // do nothing because the video is not playing
    }
    }