
How to stop onTime Event?
Hello,
on a keyup event, I am checking that a certain element has focus; if the keycode (spacebar in this case) is correct, I use onTime to stop the player at a specific time. If it does not have focus, then keycode is irrelevant and onTime should not be run. However, onTime continues to run and stop the player after the first set of conditions are satisfied (focus and spacebar). Is there a way to remove onTime in this case?
my code:
$(".playlistPanel1").focusin().bind('keyup', function(e) {
var code = e.keyCode || e.which;
if (code == 32) { //SPACE
$('.playlistPanel1 input').each(function(){ // attempt to clear any hidden focused elements
$(this).trigger('blur');
});
$this.seek($("#starttimeEntry").val()); //play at specific start time
$this.play(true);
$this.onTime(function (event) { // **continues to run outside of conditional**
if (event.position >= $("#endtimeEntry").val()) {
jwplayer().pause(true); //pause at specific start time
}
// kill onTime here?
});
// kill onTime here?
} else {
// kill onTime here?
}
});
Or am I using onTime in the wrong place in this case?