html5视频元素,开始和结束时间 [英] html5 video element, start and end times

查看:556
本文介绍了html5视频元素,开始和结束时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html5视频元素.

I have an html5 video element.

 <video id="video" loop="loop">
   <source src="src.mov">
</video>

我希望它在视频中的某个时间(比如说... 10秒)开始并在某个时间(27秒)结束

I want it to start at a certain time in the video (lets say... 10 seconds) and end at a certain time (27 seconds)

我知道您可以使用JavaScript进行此操作,但是我想使用html进行此操作.视频元素是否有开始/结束时间标签?

I know that you can do this in JavaScript, however I want to do this in html. Is there a start / end time tag for the video element?

推荐答案

您可以通过将开始和结束时间附加到源URL来指定播放范围.

时间应采用以下格式:

#t=[starttime][,endtime]

来自MDN:

媒体元素URI规范的播放范围部分已添加到Gecko 9.0(Firefox 9.0/Thunderbird 9.0/SeaMonkey 2.6).

The playback range portion of the media element URI specification was added to Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6).

下面是一个播放视频的示例,该视频从第二秒开始,到第二秒3:结束.

Here's an example to play a video, starting from second 2 and ending at second 3:

<video controls autoplay> 
  <source src=http://techslides.com/demos/sample-videos/small.webm#t=2,3 type=video/webm> 
  <source src=http://techslides.com/demos/sample-videos/small.ogv#t=2,3 type=video/ogg> 
  <source src=http://techslides.com/demos/sample-videos/small.mp4#t=2,3 type=video/mp4>
  <source src=http://techslides.com/demos/sample-videos/small.3gp#t=2,3 type=video/3gp>
</video>

参考:

媒体片段URI的时间维度
Mozilla集成记录(错误648595)

示例视频来自 techslides.com

Temporal Dimension of Media Fragments URI
Record of Mozilla integration (bug 648595)

Sample videos are from techslides.com

这篇关于html5视频元素,开始和结束时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆