source: trunk/fl5/src/com/longtailvideo/jwplayer/utils/NetClient.as @ 807

Revision 807, 3.2 KB checked in by pablo, 3 years ago (diff)
  • Fixed some bugs in RTMP dynamic / load balanced streams
  • Prevent fullscreen events from firing multiple resizes
  • PlaylistItemLevels can include streamer
Line 
1/**
2 * Object that catches and forwards calls invoked by NetStream / NetConnection.
3 **/
4package com.longtailvideo.jwplayer.utils {
5       
6       
7        public dynamic class NetClient {
8                /** Function to callback all events to **/
9                private var callback:Object;
10               
11               
12                /** Constructor. **/
13                public function NetClient(cbk:Object):void {
14                        callback = cbk;
15                }
16               
17                /** Forward calls to callback **/
18                private function forward(dat:Object, typ:String):void {
19                        dat['type'] = typ;
20                        var out:Object = new Object();
21                        for (var i:Object in dat) {
22                                out[i] = dat[i];
23                        }
24                        callback.onClientData(out);
25                }
26               
27                /** Checking the available bandwidth. **/
28                public function close(... rest):void {
29                        forward({close: true}, 'close');
30                }
31               
32                /** Checking the available bandwidth. **/
33                public function onBWCheck(... rest):Number {
34                        return 0;
35                }
36               
37                /** Receiving the bandwidth check result. **/
38                public function onBWDone(... rest):void {
39                        if (rest.length > 0) {
40                                forward({bandwidth: rest[0]}, 'bandwidth');
41                        }
42                }
43               
44                /** Captionate caption handler. **/
45                public function onCaption(cps:String, spk:Number):void {
46                        forward({captions: cps, speaker: spk}, 'caption');
47                }
48               
49                /** Captionate metadata handler. **/
50                public function onCaptionInfo(obj:Object):void {
51                        forward(obj, 'captioninfo');
52                }
53               
54                /** Cuepoint handler. **/
55                public function onCuePoint(obj:Object):void {
56                        forward(obj, 'cuepoint');
57                }
58               
59                /** CDN subscription handler. **/
60                public function onFCSubscribe(obj:Object):void {
61                        forward(obj, 'fcsubscribe');
62                }
63               
64                /** Get headerdata information from netstream class. **/
65                public function onHeaderData(obj:Object):void {
66                        var dat:Object = new Object();
67                        var pat:String = "-";
68                        var rep:String = "_";
69                        for (var i:String in obj) {
70                                var j:String = i.replace("-", "_");
71                                dat[j] = obj[i];
72                        }
73                        forward(dat, 'headerdata');
74                }
75               
76                /** Image data (iTunes-style) handler. **/
77                public function onID3(... rest):void {
78                        forward(rest[0], 'id3');
79                }
80               
81                /** Image data (iTunes-style) handler. **/
82                public function onImageData(obj:Object):void {
83                        forward(obj, 'imagedata');
84                }
85               
86                /** Lastsecond call handler. **/
87                public function onLastSecond(obj:Object):void {
88                        forward(obj, 'lastsecond');
89                }
90               
91                /** Get metadata information from netstream class. **/
92                public function onMetaData(obj:Object):void {
93                        forward(obj, 'metadata');
94                }
95               
96                /** Receive NetStream playback codes. **/
97                public function onPlayStatus(... rest):void {
98                        for each (var dat:Object in rest) {
99                                if (dat && dat.hasOwnProperty('code')) {
100                                        if (dat.code == "NetStream.Play.Complete") {
101                                                forward(dat, 'complete');
102                                        } else {
103                                                forward(dat, 'playstatus');
104                                        }
105                                }
106                        }
107                }
108               
109                /** Quicktime broadcaster pixel. **/
110                public function onSDES(... rest):void {
111                        forward(rest[0], 'sdes');
112                }
113               
114                /** Receiving the bandwidth check result. **/
115                public function onXMPData(... rest):void {
116                        forward(rest[0], 'xmp');
117                }
118               
119                public function onXMP(... rest):void {
120                        onXMPData(rest);
121                }
122
123                /** RTMP Sample handler (what is this for?). **/
124                public function RtmpSampleAccess(... rest):void {
125                        forward(rest[0], 'rtmpsampleaccess');
126                }
127               
128                /** Textdata handler (MP4 text tracks). **/
129                public function onTextData(obj:Object):void {
130                        forward(obj, 'textdata');
131                }
132               
133        }
134}
Note: See TracBrowser for help on using the repository browser.