寻求html5视频中的一点 [英] seek to a point in html5 video

查看:109
本文介绍了寻求html5视频中的一点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在网页中显示 html5视频中的特定点?我的意思是,我可以输入一个特定的时间值(例如 01:20:30:045 )并让玩家控制(滑块)移动到该点并从该点开始播放以后?

Is it possible to seek to a particular point in html5 video displayed in a web page? I mean ,can I input a particular time value (say 01:20:30:045 ) and have the player control (slider) move to that point and play from that point onwards?

在早期版本的mozilla vlcplugin 我认为这可以通过 seek(秒,is_relative)方法..但我想知道这是否可以在html视频中使用。

In older version of mozilla vlcplugin I think this is possible by seek(seconds,is_relative) method..but I would like to know if this is possible in html video.

编辑:

我创建了包含视频的页面,并添加了如下所示的javascript。当我点击链接时,它会显示点击的时间..但它不会增加播放位置..但继续正常播放。

I created the page with video and added javascript as below.When I click on the link ,it displays the time of click..but it doesn't increment the play location..but continues to play normally.

视频播放位置是否应该更改?

Shouldn't the video play location get changed?

html

<video id="vid" width="640" height="360" controls>
       <source src="/myvid/test.mp4" type="video/mp4" /> 
</video>
<a id="gettime" href="#">time</a>
<p>
you clicked at:<span id="showtime"> </span> 
</p>

javascript

javascript

$(document).ready(function(){
    var player = $('#vid').get(0);
    $('#gettime').click(function(){
            if(player){
                current_time=player.currentTime;
                $('#showtime').html(current_time+" seconds");
                player.currentTime=current_time+10;
            }
        });
}
);


推荐答案

您可以使用 v。 currentTime =秒; 寻找给定的位置。

You can use v.currentTime = seconds; to seek to a given position.

参考: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentTime

这篇关于寻求html5视频中的一点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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