As3.0 视频缓冲、下载总结

来源:http://www.cuplayer.com/player/PlayerCodeAs/2012/0913404.html

 

利用NetStream的以下属性:

bufferTime — 缓冲区大小。可设置(单位为秒),默认为0.1秒
bufferLength — 已进入缓冲区的秒数
bufferLength / bufferTime — 已缓冲的百分比
bytesLoaded — 已下载的字节数
bytesTotal — 总字节数
bytesLoaded / bytesTotal — 已下载的百分比

    1. package {  
    2.  import flash.display.Sprite;  
    3.  import flash.events.Event;  
    4.  import flash.events.MouseEvent;  
    5.  import flash.media.Video;  
    6.  import flash.net.NetConnection;  
    7.  import flash.net.NetStream;  
    8.  import flash.text.TextField;  
    9.  import flash.text.TextFieldAutoSize;  
    10.  public class Sample0623 extends Sprite  
    11.  {  
    12.   private var textBox:TextField;  
    13.   private var ns:NetStream;  
    14.  
    15.   public function Sample0623()  
    16.   {  
    17.    //Video   
    18.    var nc:NetConnection = new NetConnection();  
    19.    nc.connect(null);  
    20.    ns = new NetStream(nc);  
    21.    ns.client = this;  
    22.    ns.bufferTime = 5;  
    23.    ns.play("demo.flv");  
    24.    var video:Video = new Video();  
    25.    video.attachNetStream(ns);  
    26.    this.addChild(video);  
    27.  
    28.    //Text   
    29.    textBox = new TextField();  
    30.    textBox.autoSize = TextFieldAutoSize.CENTER;  
    31.    textBox.multiline = true;  
    32.    textBox.x = 100;  
    33.    textBox.y = 250;  
    34.    this.addChild(textBox);  
    35.  
    36.    stage.addEventListener(Event.ENTER_FRAME,onEnterFrame);  
    37.   }  
    38.  
    39.   private function onEnterFrame(event:Event):void  
    40.   {  
    41.    textBox.text = "";  
    42.    textBox.appendText("酷播cuplayer缓冲区大小是:"+ns.bufferTime+"\n");  
    43.    textBox.appendText("已进入缓冲区的秒数:"+ns.bufferLength+"\n");  
    44.    textBox.appendText("已缓冲的百分比:"+ Math.round((ns.bufferLength/ns.bufferTime)*100) +"%\n");  
    45.    textBox.appendText("已下载的字节数:"+ns.bytesLoaded+"\n");  
    46.    textBox.appendText("酷播cuplayer总字节数:"+ns.bytesTotal+"\n");  
    47.    textBox.appendText("已下载的百分比:"+ Math.round((ns.bytesLoaded/ns.bytesTotal)*100) +"%\n");  
    48.   }  
    49.   public function onMetaData(infoObject:Object):void  
    50.   {  
    51.   }  
    52.  }  

转载于:https://www.cnblogs.com/-yan/p/4436354.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值