Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
124 lines (104 sloc) 3.59 KB
/*** RED5 Open Source Flash Server - http://www.osflash.org/red5** Copyright (c) 2006-2009 by respective authors (see below). All rights reserved.** This library is free software; you can redistribute it and/or modify it under the* terms of the GNU Lesser General Public License as published by the Free Software* Foundation; either version 2.1 of the License, or (at your option) any later* version.** This library is distributed in the hope that it will be useful, but WITHOUT ANY* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.** You should have received a copy of the GNU Lesser General Public License along* with this library; if not, write to the Free Software Foundation, Inc.,* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/import org.red5.net.Stream;import org.red5.samples.livestream.videoconference.Connection;import org.red5.samples.livestream.videoconference.VideoPool;import org.red5.utils.Delegate;import com.gskinner.events.GDispatcher;import flash.external.*;class org.red5.samples.livestream.videoconference.Subscriber extends MovieClip {// Constants: public static var CLASS_REF = org.red5.samples.livestream.videoconference.Subscriber; public static var LINKAGE_ID:String = "org.red5.samples.livestream.videoconference.Subscriber";// Public Properties: public var connected:Boolean = false; public var videoStream:String;// Private Properties: private var stream:Stream; private var checkTime:Number; private var si:Number;// UI Elements: public var videoPool:VideoPool;// ** AUTO-UI ELEMENTS ** private var userName:TextField; private var publish_video:Video;// ** END AUTO-UI ELEMENTS **// Initialization: private function Subscriber() {} private function onLoad():Void { configUI(); }// Public Methods: public function setUserName(p_name:String):Void { } public function streamStop(evtObj:Object):Void { _global.tt("SUBSCRIBER OUT! " + evtObj.code); reset(); } public function streamStart(evtObj:Object):Void { _global.tt("SUBSCRIBER ALIVE?"); si = setInterval(this, "doubleCheckTime", 1500); } public function subscribe(p_subscriptionID:String, p_connection:Connection):Void { _global.tt("Subscriber.subscribe", p_subscriptionID); videoStream = p_subscriptionID; stream = new Stream(p_connection); // set to false to NOT see status events //stream.debug = true; //stream.setBuffer(1); // add listener for when someone disconnects stream.addEventListener("unpublishNotify", Delegate.create(this, streamStop)); stream.addEventListener("playPublishNotify", Delegate.create(this, streamStart)); stream.addEventListener("bufferFlush", Delegate.create(this, streamStart)); // play the stream stream.play(p_subscriptionID, -1); checkTime = stream.time; //si = setInterval(this, "doubleCheckTime", 1500); // connect to the video object publish_video.attachVideo(stream); // set connected connected = true; }// Semi-Private Methods:// Private Methods: private function doubleCheckTime():Void { clearInterval(si); if(checkTime == stream.time) reset(); } private function configUI():Void { userName.text = ""; onRelease = function() { _global.tt('Subscriber ' + this.videoStream + ' clicked.'); ExternalInterface.call("spotlight", this.videoStream); } }; private function reset():Void { _global.tt("SUBSCRIBER RESET " + videoStream); videoPool.removeSubscriber(this); connected = false; userName.text = ""; publish_video.clear(); stream.close(); }}