[英]HTML5 video seeking
如何讓我的視頻播放器跳過/尋找到某個時間。 我已經開始使用它,它可以在頁面首次加載(在Chrome中)但在任何其他瀏覽器中都無效。 我也有一個閃回落,這可能是一個痛苦,但目前優先考慮的事情的HTML方面主要問題是它在Chrome之外不起作用!
編輯:這現在適用於IE9,Chrome和Firefox。 但是,不是閃存后備!
以下是我到目前為止的嘗試。
到目前為止我正在使用以下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秒”等的上下文。
seekToTime:function( value )
{
var seekToTime = this.videoPlayer.currentTime + value;
if( seekToTime < 0 || seekToTime > this.videoPlayer.duration )
return;
this.videoPlayer.currentTime = seekToTime;
}
這是我們正在使用的搜索功能。 這是MooTools的語法,但你會明白這一點。 希望能幫助到你。
我猜你用js和css構建了自己的控件?! 好吧,因此你必須擴展你的swf,你可以從javascript調用你的搜索功能。 外部接口是你的朋友:在actionscript / flash中:
import flash.external.ExternalInterface;
ExternalInterface.addCallback( "methodName", this, method );
function method() { trace("called from javascript"); }
通過javascript調用此方法
function callAS() {
swf.methodName();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.