【发布时间】:2012-03-07 20:50:15
【问题描述】:
如何让我的视频播放器跳过/搜索到某个时间。我对此进行了尝试,它在页面首次加载(在 Chrome 中)时有效,但在任何其他浏览器中均无效。我也有一个闪退,这可能会很痛苦,但现在优先考虑的是 HTML 方面 主要问题是它不能在 Chrome 之外运行!
编辑:现在可以在 IE9、Chrome 和 Firefox 中使用。但是,不能使用 Flash 后备!
以下是我目前的尝试。
到目前为止,我正在使用以下 JS:
<script language="javascript">
$(function () {
var v = $("#video").get(0);
$('#play').click(function(){
v.play();
});
$('.s').click(function(){
alert("Clicked: "+$(this).html() +"- has time of -" + $(this).attr('s') );
v.currentTime = $(this).attr('s'); v.play();
});
});
</script>
以下链接:
<video id="video" controls width="500">
<!-- if Firefox -->
<source src="video.ogg" type="video/ogg" />
<!-- if Safari/Chrome-->
<source src="video.mp4" type="video/mp4" />
<!-- If the browser doesn't understand the <video> element, then reference a Flash file. You could also write something like "Use a Better Browser!" if you're feeling nasty. (Better to use a Flash file though.) -->
<object type="application/x-shockwave-flash" data="player.swf"
width="854" height="504">
<param name="allowfullscreen" value="true">
<param name="allowscriptaccess" value="always">
<param name="flashvars" value="file=video.mp4">
<!--[if IE]><param name="movie" value="player.swf"><![endif]-->
<p>Your browser can’t play HTML5 video.</p>
</object>
</video>
在具有 s 类和自定义属性 s=60 “60 秒”等的按钮的上下文中。
【问题讨论】:
标签: javascript jquery html html5-video