在HTML5视频中,如何从长视频播放小剪辑?

前端之家收集整理的这篇文章主要介绍了在HTML5视频中,如何从长视频播放小剪辑?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想从长达10分钟的长视频文件显示一个小剪辑.这段视频将在90秒的时间偏移/寻道时间开始,持续时间为45秒.我怎样才能做到这一点 ?

解决方法

菲利普·布朗是对的.你可以通过js控制yout html播放器来解决这个问题.例如在这种情况下,视频将自动启动,并将播放视频文件应该00:10分钟到00:40分钟
<video id="yourVideoplayer" width="640" height="480" preload="auto"> //preload="auto" buffers the video if initialize. you cannot seek a video which isn t buffering already
  <source src="test.mp4" type="video/mp4" />
  <source src="test.ogv" type="video/ogg" /> 
  This browser is not compatible with HTML 5
</video>

<script type="text/javascript">
   window.onload = playVideoTeaserFrom(10,40);   //this event will call the function after page was loaded

   function playVideoTeaserFrom (startTime,endTime) {
       var videoplayer = document.getElementById("yourVideoplayer");  //get your videoplayer

       videoplayer.currentTime = starttime; //not sure if player seeks to seconds or milliseconds
       videoplayer.play();

       //call function to stop player after given intervall
       var stopVideoAfter = (endTime - startTime) * 1000;  //* 1000,because Timer is in ms
       setTimeout(function(){
           videoplayer.stop();
       },stopVideoAfter);

   }
 </script>

可能会有一些错误,但我想你会得到点

原文链接:https://www.f2er.com/html5/168109.html

猜你在找的HTML5相关文章