Ignore:
Timestamp:
08/17/10 13:54:17 (21 months ago)
Author:
shiretu
Message:

-- work on applestreamingclient

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/applications/applestreamingclient/flex/src/applestreamingclient.mxml

    r2 r80  
    1111                         
    1212                        import mx.controls.Alert; 
     13                        import mx.utils.ObjectUtil; 
     14                         
     15                        import org.osmf.net.dynamicstreaming.SufficientBandwidthRule; 
    1316                         
    1417                        private var _connectData:Object; 
    1518                        [Bindable] 
    1619                        private var _connection:Engine; 
     20                        private var _bwInfoTimer:Timer; 
    1721                         
    1822                        private function Init():void{ 
     
    2731                                player.Initialize(); 
    2832                                ConnectDisconnect(); 
     33                                pnlInfo.x=player.x; 
     34                                pnlInfo.y=player.y+player.height-pnlInfo.height; 
     35                                _bwInfoTimer = new Timer(1000); 
     36                                _bwInfoTimer.addEventListener(TimerEvent.TIMER,ShowBwInfo); 
     37                                txtAppleConnectingString.text="http://mlbvod-akc.mlb.com/mlbam/2010/04/08/MLB_GAME_VIDEO_LANPIT_HOME_20100408/master_wired.m3u8|bl8D2EASEF8WUrzZ+y3o0NiQyAk=|playback=HTTP_CLOUD_WIRED&contentId=7320085&appAccountName=mlb&eventId=14-263849-2010-04-08&ipid=11627706&sessionKey=GBncPsxRBV02IC9n80RP1Sdr9ew%3D"; 
     38                        } 
     39                         
     40                        private function ShowBwInfo(event:TimerEvent):void { 
     41                                _connection.Call("getBWInfo",BWInfoAvaliable); 
     42                        } 
     43                         
     44                        private function BWInfoAvaliable(info:Object):void{ 
     45                                if(info==null) 
     46                                        return; 
     47                                lblAvalivaleBws.text=""; 
     48                                for(var i:int=0;i<info.response.parameters.availableBws.length;i++){ 
     49                                        lblAvalivaleBws.text+=prettyPrint(info.response.parameters.availableBws[i]/8,"/s")+", "; 
     50                                } 
     51                                lblDetectedBw.text=prettyPrint(info.response.parameters.detectedBw/8,"/s"); 
     52                                lblSelectedBw.text=prettyPrint(info.response.parameters.selectedBw/8,"/s");; 
     53                                lblBufferLevel.text=prettyPrint(info.response.parameters.bufferLevel); 
     54                                lblMaxBufferLevel.text=prettyPrint(info.response.parameters.bufferMaxLevel); 
     55                                lblBufferLevelPercent.text=info.response.parameters.bufferLevelPercent.toPrecision(3)+"%"; 
     56                                lblBufferLevelSeconds.text=(info.response.parameters.bufferLevel/info.response.parameters.selectedBw*8).toPrecision(3)+" s"; 
     57                        } 
     58                         
     59                        private function prettyPrint(val:Number, suffix:String=""):String{ 
     60                                var result:String=""; 
     61                                var um:String="B"+suffix; 
     62                                if(val>1024){ 
     63                                        val=val/1024; 
     64                                        um="KB"+suffix; 
     65                                } 
     66                                if(val>1024){ 
     67                                        val=val/1024; 
     68                                        um="MB"+suffix; 
     69                                } 
     70                                result=val.toPrecision(4)+" "+um; 
     71                                return result; 
    2972                        } 
    3073                         
     
    3982                                } else { 
    4083                                        _connection.Disconnect(); 
     84                                        if(_bwInfoTimer!=null) 
     85                                                _bwInfoTimer.stop(); 
    4186                                } 
    4287                        } 
     
    5398                                //                              player.Play(_connection,_connection.TSStreams[dgFlvs.selectedIndex].data); 
    5499                                _connection.Call("setupStream",null,txtAppleConnectingString.text); 
     100                                _bwInfoTimer.start(); 
    55101                        } 
    56102                ]]> 
    57103        </mx:Script> 
    58         <mx:VBox paddingLeft="10" paddingTop="10" paddingRight="10" paddingBottom="10" borderStyle="solid" width="100%" height="100%"> 
     104        <mx:VBox id="vBox" paddingLeft="10" paddingTop="10" paddingRight="10" paddingBottom="10" borderStyle="solid" width="100%" height="100%"> 
    59105                <mx:HBox width="100%"> 
    60106                        <mx:Button label="Show logs..." id="btnLogs" click="LogsWindow.Show(this);"/> 
     
    65111                        <mx:TextInput text="" id="txtAppleConnectingString" width="100%"/> 
    66112                </mx:HBox> 
    67                 <ns1:VideoPlayer width="100%" height="100%" id="player"/> 
     113                <ns1:VideoPlayer width="100%" height="100%" id="player" enabled="{_connection.IsConnected}" /> 
    68114        </mx:VBox> 
     115        <mx:Panel id="pnlInfo" width="500" x="10" y="267" title="Bandwidth info"> 
     116                <mx:VBox width="100%" height="100%"> 
     117                        <mx:HBox width="100%" borderStyle="solid"> 
     118                                <mx:Label text="Available bws:" width="50%"/> 
     119                                <mx:Label id="lblAvalivaleBws" width="50%"/> 
     120                        </mx:HBox> 
     121                        <mx:HBox width="100%" borderStyle="solid"> 
     122                                <mx:Label text="Detected bw:" width="50%"/> 
     123                                <mx:Label id="lblDetectedBw" width="50%"/> 
     124                        </mx:HBox> 
     125                        <mx:HBox width="100%" borderStyle="solid"> 
     126                                <mx:Label text="Selected bw:" width="50%"/> 
     127                                <mx:Label id="lblSelectedBw" width="50%"/> 
     128                        </mx:HBox> 
     129                        <mx:HBox width="100%" borderStyle="solid"> 
     130                                <mx:Label text="Buffer level:" width="50%"/> 
     131                                <mx:Label id="lblBufferLevel" width="50%"/> 
     132                        </mx:HBox> 
     133                        <mx:HBox width="100%" borderStyle="solid"> 
     134                                <mx:Label text="Max buffer level:" width="50%"/> 
     135                                <mx:Label id="lblMaxBufferLevel" width="50%"/> 
     136                        </mx:HBox> 
     137                        <mx:HBox width="100%" borderStyle="solid"> 
     138                                <mx:Label text="Buffer level percent:" width="50%"/> 
     139                                <mx:Label id="lblBufferLevelPercent" width="50%"/> 
     140                        </mx:HBox> 
     141                        <mx:HBox width="100%" borderStyle="solid"> 
     142                                <mx:Label text="Buffer level seconds:" width="50%"/> 
     143                                <mx:Label id="lblBufferLevelSeconds" width="50%"/> 
     144                        </mx:HBox> 
     145                </mx:VBox> 
     146        </mx:Panel> 
    69147</mx:Application> 
Note: See TracChangeset for help on using the changeset viewer.