如何让我的视频播放器跳过/查找到某个时间。我已经尝试过了,它在页面第一次加载(在Chrome中)时有效,但在任何其他浏览器中都不起作用。我也有一个flash回退,这可能是一个痛苦,但现在优先考虑的是HTML方面的事情,主要问题是它不能在Chrome之外工作!
编辑:现在可以在IE9,Chrome和火狐浏览器中使用。但是,不能使用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秒“等的上下文。
发布于 2012-02-16 20:57:40
seekToTime:function( value )
{
var seekToTime = this.videoPlayer.currentTime + value;
if( seekToTime < 0 || seekToTime > this.videoPlayer.duration )
return;
this.videoPlayer.currentTime = seekToTime;
}这是我们正在使用的seek函数。它是用MooTools语法编写的,但是您会明白这一点的。希望能有所帮助。
发布于 2012-02-16 21:16:57
我猜你是用js和css构建自己的控件吧?!好的,因此你必须扩展你的swf,你可以从javascript调用你的seek函数。外部接口是您的朋友:在actionscript/flash中:
import flash.external.ExternalInterface;
ExternalInterface.addCallback( "methodName", this, method );
function method() { trace("called from javascript"); }通过javascript调用
function callAS() {
swf.methodName();
}https://stackoverflow.com/questions/9311570
复制相似问题