简体   繁体   English

HTML5视频搜索

[英]HTML5 video seeking

How can I get my video player to skip/seek to a certain time. 如何让我的视频播放器跳过/寻找到某个时间。 I have had a go at this and it works when the page first loads (In Chrome) but not in any other browser. 我已经开始使用它,它可以在页面首次加载(在Chrome中)但在任何其他浏览器中都无效。 I also have a flash fallback which could be a pain, but for now the priority is the HTML side of things The major issue is that it doesn't work outside Chrome! 我也有一个闪回落,这可能是一个痛苦,但目前优先考虑的事情的HTML方面主要问题是它在Chrome之外不起作用!

EDIT: This now works in IE9, Chrome and Firefox. 编辑:这现在适用于IE9,Chrome和Firefox。 However, not with the flash fallback! 但是,不是闪存后备!

Below is my attempt so far. 以下是我到目前为止的尝试。

I'm using the following JS so far: 到目前为止我正在使用以下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>

Which links to the following: 哪个链接到以下内容:

<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>

With the context of having buttons with a class s and custom attribute s=60 for "60 seconds" etc. 具有带有类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;
}

This is the seek function we are using. 这是我们正在使用的搜索功能。 It's in MooTools syntax, but you'll get the point. 这是MooTools的语法,但你会明白这一点。 Hope it helps. 希望能帮助到你。

i guess you built your own controls with js and css?! 我猜你用js和css构建了自己的控件?! well, therefore you have to extend your swf that you can call your seek function from javascript. 好吧,因此你必须扩展你的swf,你可以从javascript调用你的搜索功能。 external interface is your friend: in actionscript/flash: 外部接口是你的朋友:在actionscript / flash中:

 import flash.external.ExternalInterface; 

 ExternalInterface.addCallback( "methodName", this, method ); 

 function method() { trace("called from javascript"); }

call this via javascript 通过javascript调用此方法

function callAS() {
    swf.methodName();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM