Jump to content

Recommended Posts

I have a video embedded into a page like this :

 

<video id="example_video_1" class="video-js vjs-default-skin" poster="images/myPoster.jpg" controls width="350" height="260" autoplay preload="auto" data-setup="{}">
  <source type="video/mp4" src="Movie/BusConsulting350X260.mp4">
</video>

 

I want it to stop at around 27 seconds, and just stay on that frame..

 

I have seen a few things that are sort of like this but I could not get them to work.

 

one was this:

 

-----------------------------------------------------------------------------------------------------------------------

 

You can use the Media API to listen for the ended event, once this has been fired, then set the video'scurrentTime to whatever value you want (e.g. 1 second).

EDIT

Try this:

video.addEventListener('ended', function() {
this.currentTime = 1;
}, false);

Where video is a handle to your video element.

-----------------------------------------------------------------------------------------------------------------------

 

my issue with that is how to use it...

any help or explanation would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/275517-stopping-a-video-at-a-specific-time/
Share on other sites

You would need to resolve the video variable to your actual video element, perhaps using getElementById(), but apart from that it's relatively straight-forward. You bind a callback to the 'ended' event, and when the video ends your callback is called. Assuming that snippet is correct, it looks as though the callback is bound to the video object, so you can use this to refer to your video element.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.