var player = null; 
function playerReady(thePlayer) {
    player = window.document[thePlayer.id];
    addListeners();
}

// This is just the standard Listener setup -- again see the Javascript-API-Examples mentioned above
function addListeners() {
    if (player) { 
        player.addModelListener("TIME", "timeListener");
    } else {
        setTimeout("addListeners()",100);
    }
}

// This is the important part -- the function that actually does the looping 
function timeListener(obj) { 
    // Loop movie without stopping (and without flashing)
    movieLength = obj.duration;
    curTime = obj.position;
    // when movie gets near end, use a SEEK event to recycle
    // must SEEK back to start BEFORE end of movie - otherwise it stops
    if (curTime >= (movieLength - 0.1)) {
        player.sendEvent("SEEK", 0);
    }
}