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

How to restrict hte video playing to 20 sec


Hi,

i have jw platform account and am displaying videos in my wordpress website with platform api and jw player.

how i can stop the playing of video when it reaches 20 sec.

am using like this

<?php
require_once('botr/api.php');
$botr_api = new BotrAPI('xxx', 'yyy');
$response1 = $botr_api->call("/videos/show",array('video_key'=>'aaa'));
$video = $response1['video']['key'];
?>
<script type="text/javascript" src="jwplayer/jwplayer.js"></script>
<div id="testing"></div>
<script>
jwplayer("testing").setup({
playlist: "http://content.jwplatform.com/jw6/<?php echo $video; ?>.xml",
width:'50%'
});
</script>

1 Community Answers

Todd

JW Player Support Agent  
0 rated :

You can use the onTime() call in conjunction with the getPosition() call to stop the player when the time is greater than 20. I’ve also removed the controls so the viewer cannot press play. Here’s a code example. Just include this inside your <script> tag after the jwplayer().setup();

jwplayer().onTime(function(){
if (jwplayer().getPosition() > 20) {
console.log(‘Stopping the video’);
jwplayer().pause(true);
jwplayer().setControls(false);
}
});

This question has received the maximum number of answers.