Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

pause video on the specific time


Hi ,

I'm trying to make a video stop on 3:46 of the video. (226 seconds)
I was able to do it when I set the number low as 10, 20, 30. But when I set the number to 226.
It's not working. Actually it stopped working when I set it to 36. Here is the code

jwplayer("video-holder").setup({
file: "/sites/as3/media/video/<?php echo $Action->file;?>",
width: 808.5,
height: 480,
autostart: true,
mute: false,
stretching: "exactfit",
image: "/sites/as3/media/images/<?php echo $Action->thumb;?>",
events: {
onTime: function(event) {
if (file_name == "MOD_5_Making_Suggestions_V2-1.mp4"){
if (event.position == "36") {
this.seek(36).pause();

}else if(event.position == "37") {
this.seek(37).play();
}

}
},
onComplete: function(e){
this.load({
file: "/sites/as3/media/video/<?php echo $Action->file;?>",
image: "/sites/as3/media/images/<?php echo $Action->thumb;?>"
});
oncomplete:$('fieldset.video-submit').show();
}
}
});

Any idea what it could be

3 Community Answers

Cooper Reid

JW Player Support Agent  
0 rated :

Hi,

The onTime event is fired multiple times per second. I advice that you use Math.floor to round the current position down in order to properly check the current time against a number of seconds

var tenSecondEvtFired = false;
jwplayer().onTime(function(evt) {
if(Math.floor(evt.position) == 10 && !tenSecondEvtFired) {
// ten second hit
tenSecondEvtFired = true;
}
});

Kind Regards,
Cooper

ppredaswad

User  
0 rated :

Hi Cooper,

Thank you.

I use Math.floor() to round the current position. And it works!! but the problem is I would like to user to click play and the video resume playing. It seems like it stuck on the first condition because of Math.floor().

jwplayer("video-holder").setup({
file: "/sites/as3/media/video/<?php echo $Action->file;?>",
width: 808.5,
height: 480,
autostart: true,
mute: false,
stretching: "exactfit",
image: "/sites/as3/media/images/<?php echo $Action->thumb;?>",
events: {
onTime: function(event) {
if (file_name == "MOD_5_Making_Suggestions_V2-1.mp4"){
if (Math.floor(event.position) == "226") {
this.seek(226).pause();

}else if(Math.floor(event.position) == "227") {
this.seek(227).play();
}

}
},
onComplete: function(e){
this.load({
file: "/sites/as3/media/video/<?php echo $Action->file;?>",
image: "/sites/as3/media/images/<?php echo $Action->thumb;?>"
});
oncomplete:$('fieldset.video-submit').show();
}
}
});

Any idea?

Pimpisa

Cooper Reid

JW Player Support Agent  
0 rated :

Pimpisa,
You neglected the flag which is vital. In my example: var tenSecondEvtFired = false;

-Cooper

This question has received the maximum number of answers.