如何检测,当视频缓冲? [英] How to detect when video is buffering?

查看:319
本文介绍了如何检测,当视频缓冲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我的问题涉及与Flash AS3视频缓冲。 (流式或渐进),我希望能够检测到当视频被缓冲,这样我就可以显示某种动画让用户知道要等一点点时间。

目前我的影片将启动,举行第1帧3-4秒,然后播放。均田给IM pression该视频被暂停或损坏:(

更新

由于 iandisme 我相信我遇到了正确的方向了。 <一href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/NetStatusEvent.html#info"相对=nofollow>将NetStatusEvent从LiveDocs中的。在我看来,这是工作中的关键地位NetStream.Buffer.Empty所以我加了一些code。在那里,看看这会触发我动画或跟踪语句。没有运气,但是当缓冲区已满,会触发我的code:/也许我的视频总是介于 Buffer.Empty Buffer.Full 这就是为什么它不会触发任何code当我测试案例 Buffer.Empty

当前code

 公共职能的netStatusHandler(事件:将NetStatusEvent):无效
  {
     //处理网络状态事件
     开关(event.info。code)

        {
            案NetStream.Buffer.Empty:
                  跟踪(☼☼☼缓冲!); //&LT;  - 从来没有痕迹
                  的addChild(bufferLoop); //&LT;  - 不执行
            打破;

            案NetStream.Buffer.Full:
                  跟踪(☼☼☼FULL!); //&LT;  - 跟踪作品在这里
                  removeChild之(bufferLoop); //&LT;  - 让做任何其他的code
            打破;

            案NetStream.Buffer.Flush:
                  跟踪(☼☼☼FLUSH!);
                  //不知道这是非常重要的
            打破
        }
    }
 

解决方案

您使用自定义轧球员?我知道FLVPlayback类有一个<一个href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html#event%3AbufferingStateEntered"相对=nofollow>缓存事件的内置

如果你不使用的FLVPlayback,NetStream对象会触发将NetStatusEvent,其中包括一个<一个href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/NetStatusEvent.html#info"相对=nofollow> info对象每次启动或停止缓冲时间。您应该能够捕捉到这一事件和播放/隐藏动画这一点。

my question today deals with Flash AS3 video buffering. (Streaming or Progressive) I want to be able to detect when the video is being buffered, so I can display some sort of animation letting the user know to wait just a little longer.

Currently my video will start up, hold on frame 1 for 3-4 secs then play. Kinda giving the impression that the video is paused or broken :(

Update

Thanks to iandisme I believe I'm faced in the right direction now. NetStatusEvent from livedocs. It seems to me that the key status to be working in is "NetStream.Buffer.Empty" so I added some code in there to see if this would trigger my animation or a trace statement. No luck yet, however when the Buffer is full it will trigger my code :/ Maybe my video is always somewhere between Buffer.Empty and Buffer.Full that's why it won't trigger any code when I test case for Buffer.Empty?

Current Code

public function netStatusHandler(event:NetStatusEvent):void 
  {
     // handles net status events
     switch (event.info.code) 

        {
            case "NetStream.Buffer.Empty":
                  trace("☼☼☼ Buffering!"); //<- never traces
                  addChild(bufferLoop);    //<- doesn't execute
            break;

            case "NetStream.Buffer.Full":
                  trace("☼☼☼ FULL!");      //<- trace works here
                  removeChild(bufferLoop); //<- so does any other code
            break;

            case "NetStream.Buffer.Flush":
                  trace("☼☼☼ FLUSH!");
                  //Not sure if this is important
            break
        }
    }

解决方案

Are you using a custom-rolled player? I know the FLVPlayback class has a buffering event built-in.

If you're not using FLVPlayback, the NetStream object fires a netStatusEvent that includes an info object every time it starts or stops buffering. You should be able to capture that event and play/hide your animation with that.

这篇关于如何检测,当视频缓冲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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