// SegmentMarker

var segmentMarker = {
    
    mkin: 0,
    mkout: 0,

    markIn: function() {
        // Besoin d'arrondir à cause de la precision limitee
        // des cuepoints.
        this.mkin = Math.round($f().getTime() * 10) / 10;
        $("#btMarkOut").removeAttr("disabled");
        $("#frmIn").val(this.mkin * 1000);
    },
    
    markOut: function() {
        player = $f();
        player.pause();
        this.mkout = Math.round(player.getTime() * 10) / 10;
        $("#btPlaySegment").removeAttr("disabled");
        $("#frmOut").val(this.mkout * 1000);
        $("#mkin").text(this.mkin);
        $("#mkout").text(this.mkout);
        $("#segmentForm").show();
        // Arrete la lecture sur la marque de sortie de segment
        player.onCuepoint([this.mkout * 1000],
                          function(clip, cue) {
                              segmentMarker.stopOnOut(cue);
                          });
    },

    playSegment: function() {
        player = $f();
        player.seek(this.mkin);
        player.play();
    },

    stopOnOut: function(cuepoint) {
        if (cuepoint == this.mkout * 1000)
            $f().pause();
    }

};
