- Timestamp:
- 08/17/10 13:54:17 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/applications/applestreamingclient/flex/src/applestreamingclient.mxml
r2 r80 11 11 12 12 import mx.controls.Alert; 13 import mx.utils.ObjectUtil; 14 15 import org.osmf.net.dynamicstreaming.SufficientBandwidthRule; 13 16 14 17 private var _connectData:Object; 15 18 [Bindable] 16 19 private var _connection:Engine; 20 private var _bwInfoTimer:Timer; 17 21 18 22 private function Init():void{ … … 27 31 player.Initialize(); 28 32 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; 29 72 } 30 73 … … 39 82 } else { 40 83 _connection.Disconnect(); 84 if(_bwInfoTimer!=null) 85 _bwInfoTimer.stop(); 41 86 } 42 87 } … … 53 98 // player.Play(_connection,_connection.TSStreams[dgFlvs.selectedIndex].data); 54 99 _connection.Call("setupStream",null,txtAppleConnectingString.text); 100 _bwInfoTimer.start(); 55 101 } 56 102 ]]> 57 103 </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%"> 59 105 <mx:HBox width="100%"> 60 106 <mx:Button label="Show logs..." id="btnLogs" click="LogsWindow.Show(this);"/> … … 65 111 <mx:TextInput text="" id="txtAppleConnectingString" width="100%"/> 66 112 </mx:HBox> 67 <ns1:VideoPlayer width="100%" height="100%" id="player" />113 <ns1:VideoPlayer width="100%" height="100%" id="player" enabled="{_connection.IsConnected}" /> 68 114 </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> 69 147 </mx:Application>
Note: See TracChangeset
for help on using the changeset viewer.
