如何使用html 5跳转到视频的位置 [英] how to jump to a location of video using html 5

查看:885
本文介绍了如何使用html 5跳转到视频的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用html5视频标签来播放我的视频。
如何设置视频开始播放的时间。

I want to use html5 video tag to play my video. How can I set the time from which the video starts playing.

例如我的视频是90秒,我想在30秒开始播放

for example my video is 90 seconds long i want to start playing at 30 seconds

  <video width="320" height="240" controls>
  <source src="<?php echo base_url() ?>/programs/prg1.mp4" type="video/mp4">
  Your browser does not support the video tag.
  </video>

请帮帮我

推荐答案

来自 http://blog.grio.com/2012/08/how-to-seek-an-html5-video-at-a-specific-time-on-load.html

如何在Loadby Peter Tubig的特定时间寻找HTML5视频

HTML:

<video id="video1" width="320" height="240">
     <source src="movie.mp4" type="video/mp4" />
</video>

Javascript:

Javascript:

document.getElementById("video1").currentTime = 10;

Javascript语句将video1视频的当前时间设置为10秒标记。但是,这仅在浏览器已加载视频的元数据时才有效。元数据包含相关的视频信息,例如尺寸和持续时间。知道视频的持续时间是浏览器搜索视频所必需的。如果没有,则不会设置当前时间(保持为0)。可能发生这种情况的情况是网页想要在页面加载的特定时间播放视频。

The Javascript statement sets the video1 video’s current time to the 10-second mark. However, this will only work if the browser has already loaded the video’s metadata. The metadata contains pertinent video information such as dimensions and duration. Knowing the video’s duration is required for the browser to seek the video. If it doesn’t have that, then current time will not be set (remains 0). A scenario where this could happen is when a webpage wants to play a video at a specific time when the page loads.

这篇关于如何使用html 5跳转到视频的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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