|
From: <tre...@us...> - 2008-02-27 01:47:06
|
Revision: 776
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=776&view=rev
Author: trevorolio
Date: 2008-02-26 17:45:14 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
A rough but working Flex client which works with the wowza module to create a separate audio space for each ogoglio space.
Modified Paths:
--------------
maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml
maven/trunk/ogoglio-avserver/client/html-template/index.template.html
Modified: maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml
===================================================================
--- maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml 2008-02-27 01:44:25 UTC (rev 775)
+++ maven/trunk/ogoglio-avserver/client/OgoglioChat.mxml 2008-02-27 01:45:14 UTC (rev 776)
@@ -5,22 +5,49 @@
<![CDATA[
import com.ogoglio.chat.client.UserStream;
- private var streamURL:String = "rtmp://localhost:1935/videochat/";
- private var streamName:String = "test" + Math.random();
+ private var streamURL:String = "rtmp://10.0.2.2:1935/ogoglio/";
+ private var streamName:String = null;
+ private var username:String = null
+ private var spaceId:String = null
private var netConnection:NetConnection = null;
- private var userStream:UserStream = null;
-
private var mic:Microphone = null;
private var outgoingNetStream:NetStream = null;
+ private var userStreams:Dictionary = new Dictionary();
+
public function initAudio():void {
+ trace("Initializing Ogoglio Chat Client");
+ username = getParameter("username");
+ spaceId = getParameter("spaceID");
+ if(username == null || spaceId == null){
+ statusLabel.text = "No username or spaceID Parameter";
+ pushToTalkButton.enabled = false;
+ muteCheckBox.enabled = false;
+ trace("No username parameter");
+ return;
+ }
+ streamName = spaceId + "-" + username;
+ trace("Stream name is " + streamName);
+
trace("Initializing audio");
initMicrophone();
listen();
}
+
+
+ public function getParameter(name:String):String {
+ if(typeof getUrlParameters()[name] != undefined && getUrlParameters()[name] != null){
+ return getUrlParameters()[name];
+ }
+ if(typeof Application.application.parameters[name] != undefined && Application.application.parameters[name] != null){
+ return Application.application.parameters[name];
+ }
+ return null;
+ }
+
public function initMicrophone():void {
mic = Microphone.getMicrophone();
if(mic == null){
@@ -35,17 +62,10 @@
}
public function startTalk():void {
- if(mic == null){
+ if(mic == null || outgoingNetStream == null){
return;
}
- if(outgoingNetStream == null){
- outgoingNetStream = new NetStream(netConnection);
- prepNetStream(outgoingNetStream);
- outgoingNetStream.attachAudio(mic);
- outgoingNetStream.publish(streamName);
- } else {
- outgoingNetStream.attachAudio(mic);
- }
+ outgoingNetStream.attachAudio(mic);
statusLabel.text = "Talking";
}
@@ -92,10 +112,11 @@
statusLabel.text = "Setup...";
netConnection = new NetConnection();
-
+
var client:Object = new Object();
client.onMetaData = onMetaData;
client.onBWDone = onBWDone;
+ client.streamListChanged = streamListChanged;
netConnection.client = client;
netConnection.objectEncoding = ObjectEncoding.AMF0;
@@ -104,22 +125,50 @@
netConnection.connect(streamURL);
}
+
private function onMuteChange():void {
trace("On mute state change: " + muteCheckBox.selected);
-
- if(userStream == null){
- return;
+ for(var stream:String in userStreams){
+ trace("Muting " + stream);
+ userStreams[stream].setMute(muteCheckBox.selected);
}
- userStream.setMute(muteCheckBox.selected);
}
+
+ public function streamListChanged():String { //called by the server to indicate that streams left or arrived
+ trace("Stream List Changed!");
+ requestStreamList();
+ return "Ok";
+ }
+
+ private function requestStreamList():void{
+ trace("Requesting stream list");
+ netConnection.call("getStreamList", new Responder(handleStreamList), streamName);
+ }
+
+ private function handleStreamList(streamList:String):void {
+ trace("New stream list: " + streamList);
+ var streams:Array = streamList.split(",");
+ for(var i:int = 0; i < streams.length; i++){
+ if(userStreams[streams[i]] == null && streams[i] != streamName){
+ userStreams[streams[i]] = new UserStream(netConnection, streams[i]);
+ }
+ }
+ }
+
private function onNetStatus(evt:NetStatusEvent):void {
switch(evt.info.code) {
case "NetConnection.Connect.Success":
trace("Connection success!");
- statusLabel.text = "Connected";
-
- userStream = new UserStream(netConnection, streamName);
+
+ statusLabel.text = "Publishing...";
+ outgoingNetStream = new NetStream(netConnection);
+ prepNetStream(outgoingNetStream);
+ outgoingNetStream.publish(streamName);
+
+ statusLabel.text = "Streaming...";
+ requestStreamList();
+
statusLabel.text = "Playing";
pushToTalkButton.enabled = true;
@@ -143,6 +192,8 @@
pushToTalkButton.enabled = false;
muteCheckBox.enabled = false;
break;
+ case "NetStream.Publish.Start":
+ case "NetStream.Play.Reset":
case "NetStream.Play.Stop":
case "NetStream.Buffer.Full":
break;
@@ -151,6 +202,22 @@
}
}
+ public function getUrlParameters():Dictionary {
+ var urlParams:Dictionary = new Dictionary();
+
+ var fullUrl:String = ExternalInterface.call("eval","document.location.href");
+
+ var paramStr:String = fullUrl.split("?")[1];
+ if (paramStr != null) {
+ var params:Array = paramStr.split("&");
+ for (var i:int = 0; i < params.length; i++) {
+ var kv:Array = params[i].split("=");
+ urlParams[kv[0]] = kv[1];
+ }
+ }
+ return urlParams;
+ }
+
private function onMetaData(obj:Object):void {
trace("onMetaData");
}
Modified: maven/trunk/ogoglio-avserver/client/html-template/index.template.html
===================================================================
--- maven/trunk/ogoglio-avserver/client/html-template/index.template.html 2008-02-27 01:44:25 UTC (rev 775)
+++ maven/trunk/ogoglio-avserver/client/html-template/index.template.html 2008-02-27 01:45:14 UTC (rev 776)
@@ -70,7 +70,7 @@
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
- "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '',
+ "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + "&username=trevor" + "&spaceID=44",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|