source: trunk/as3/com/jeroenwijering/models/FCSubscribeModel.as @ 203

Revision 203, 1.4 KB checked in by jeroen, 4 years ago (diff)

fixed Bitgravity FLV streaming and some additional mini quirks

Line 
1/**
2* Manages playback of live streams through a subscription mechanism.
3**/
4package com.jeroenwijering.models {
5
6
7import com.jeroenwijering.events.*;
8import com.jeroenwijering.models.RTMPModel;
9import com.jeroenwijering.player.Model;
10
11
12import flash.events.*;
13import flash.utils.*;
14
15
16public class FCSubscribeModel extends RTMPModel {
17
18
19        /** Interval ID for subscription pings. **/
20        private var subscribe:Number;
21
22
23        /** Constructor. **/
24        public function FCSubscribeModel(mod:Model):void {
25                super(mod);
26        };
27
28
29        /** Try subscribing. **/
30        private function doSubscribe(id:String):void {
31                connection.call("FCSubscribe",null,id);
32        };
33
34
35        /** Check metadata for subscription success/failure. **/
36        override public function onData(dat:Object):void {
37                if(dat.type == 'fcsubscribe') {
38                        if(dat.code == "NetStream.Play.StreamNotFound" ) {
39                                model.sendEvent(ModelEvent.ERROR,{message:"Subscription failed: "+item['file']});
40                        } else if(dat.code == "NetStream.Play.Start") {
41                                setStream();
42                        }
43                        clearInterval(subscribe);
44                }
45                super.onData(dat);
46        };
47
48
49        /** Receive NetStream status updates. **/
50        override protected function statusHandler(evt:NetStatusEvent):void {
51                if (evt.info.code == 'NetConnection.Connect.Success') {
52                        model.sendEvent(ModelEvent.META,{info:evt.info.code});
53                        subscribe = setInterval(doSubscribe,1000,getID(item['file']));
54                } else {
55                        super.statusHandler(evt);
56                }
57        };
58
59
60};
61
62
63}
Note: See TracBrowser for help on using the repository browser.