I am new to JQuery. I have searched previous posts but couldn't find anything. I am trying to do call another function from Video Ended Event handler. its not working.
$(document).ready(function(){
// doing something
$("#video1").bind("ended", NextFrag());
});
function NextFrag(){
Window.alert("Hello World");
}
This is not working. I cannot see any alert printing "Hello World".
Basically I need to solve the above problem to do the following task. I want to play different fragments of video. The algorithm should be something like this:
$(document).ready(function(){
NextFrag();
});
function NextFrag(){
// IF First FRAGMENT do this
$("#video1").html('<source src="FirstURLFromArray.mp4" type="video/mp4"></source>' );
// ELSE DO THIS
$("#video1").bind("ended", function(){
$("#video1").html('<source src="NextURLFromArray.mp4" type="video/mp4"></source>' );
NextFrag(); // call itself again.
});
}
Any help will be very appreciated. Thanks,
$( "#video1" ).bind( "ended", NextFrag );Ditch the parens. You want to bind the function, not invoke it immediately.windowis lowercase, won't work in camelcase.