I'm trying to create a clip from a video. which have fixed start and end time. So when I click on the button then the video should start from the given time. Here's my code
<link href="{{asset('../videojs/videojs-resolution-switcher.css')}}" rel="stylesheet">
<link href="{{asset('../videojs/video-js.min.css')}}" rel="stylesheet">
<script src="{{asset('../videojs/video.js')}}"></script>
<script src="{{asset('../videojs/videojs-resolution-switcher.js')}}"></script>
<script src="{{asset('../videojs/videojs-offset.min.js')}}"></script>
<script src="{{asset('../videojs/Youtube.min.js')}}"></script>
function setSegmentTime(e)
{
var start_time = $(e).data("start-time");
var end_time = $(e).data("end-time");
var myplayer = videojs('demo-video');
myplayer.offset({
start: start_time,
end: end_time,
restart_beginning: false //Should the video go to the beginning when it ends
});
myplayer.play();
}
In this, I have used a plugin for playing a segment of the video but it is also not working. It may be the videojs version issue. https://github.com/cladera/videojs-offset
My question is that, can I play a video at a given time without using above plugin. I have checked everywhere but none of the solution is working. Thanks in advance.
Add ? autoplay=1 to the end of the sharing page link. This URL argument will make the video play automatically when the page loads. If you want the video to start playing at a specific time, also add second=15 to the end of the URL.
Pause the video where you want the viewer to begin watching the video. Right click within the YouTube video frame. From the right-click menu, select “get video URL at current time.” Now, paste the URL to wherever you are sharing the link.
Amending the URL Enter the start and stop times in whole seconds (e.g. one minute and two seconds = 62 seconds) and make sure not to include any additional characters or spaces or it will not work. ? start=67&end=80 When the above is added to the end of the YouTube URL the video will start at 1:07 and stop at 1:20.
I think currentTime is what you want.
// get
var whereYouAt = myPlayer.currentTime();
// set
myPlayer.currentTime(120); // 2 minutes into the video
more about it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With