首页 > 其他 > 详细

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

时间:2015-04-18 01:00:21      阅读:590      评论:0      收藏: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.  }  

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

原文:http://www.cnblogs.com/-yan/p/4436354.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!