zoukankan      html  css  js  c++  java
  • 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+" ");  
      43.    textBox.appendText("已进入缓冲区的秒数:"+ns.bufferLength+" ");  
      44.    textBox.appendText("已缓冲的百分比:"+ Math.round((ns.bufferLength/ns.bufferTime)*100) +"% ");  
      45.    textBox.appendText("已下载的字节数:"+ns.bytesLoaded+" ");  
      46.    textBox.appendText("酷播cuplayer总字节数:"+ns.bytesTotal+" ");  
      47.    textBox.appendText("已下载的百分比:"+ Math.round((ns.bytesLoaded/ns.bytesTotal)*100) +"% ");  
      48.   }  
      49.   public function onMetaData(infoObject:Object):void  
      50.   {  
      51.   }  
      52.  }  
  • 相关阅读:
    VM 下增加磁盘空间
    在APACHE服务器上的访问方式上去除index.php
    1
    数组累加兼eval性能测试
    webstorm软件使用记录
    gulp配置安装使用
    jQuery方法笔记
    搭建Grunt集成环境开发SASS
    msysgit使用方法
    十诫在天主教和新教之间的差别
  • 原文地址:https://www.cnblogs.com/-yan/p/4436354.html
Copyright © 2011-2022 走看看