Initial commit, ongoing refactoring and audio channels
This commit is contained in:
commit
d98eab59a3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
BIN
p2p.fla
Normal file
BIN
p2p.fla
Normal file
Binary file not shown.
BIN
p2p.swf
Normal file
BIN
p2p.swf
Normal file
Binary file not shown.
1
sqwiggle/Member.as
Normal file
1
sqwiggle/Member.as
Normal file
@ -0,0 +1 @@
|
||||
package sqwiggle {
import flash.display.Sprite;
import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.media.SoundChannel;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.display.Shape;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.utils.Timer;
public class Member extends Sprite {
public var connection :NetConnection;
public var userId :String;
public var peerId :String;
var stream:NetStream;
var video :Video;
var rectangle:Shape;
var bar:MovieClip;
var t:MovieClip;
public function Member(userId:String, peerId:String) {
this.userId = userId;
this.peerId = peerId;
rectangle = new Shape; // initializing the variable named rectangle
rectangle.graphics.beginFill(0xFF0000); // choosing the colour for the fill, here it is red
rectangle.graphics.drawRect(0, 0, 320,240); // (x spacing, y spacing, width, height)
rectangle.graphics.endFill(); // not always needed but I like to put it in to end the fill
video = new Video();
video.width = 291;
video.height = 218;
addChild(video);
bar = new fuckyou();
bar.y = video.height;
bar.visible=false;
addChild(bar);
t = new talk();
t.x = 4;
t.buttonMode=true;
t.useHandCursor=true;
t.y = video.height - 4;
addChild(t);
t.visible=false;
addEventListener(MouseEvent.MOUSE_OVER, mover);
addEventListener(MouseEvent.MOUSE_OUT, mout);
}
public function connectToVideo(videoConnection:NetConnection):void {
//trace('Connecting to id: ' + id + ', stream: ' + peerId);
stream = new NetStream(videoConnection, peerId);
stream.addEventListener(NetStatusEvent.NET_STATUS, onVideoStatus);
stream.play(this.userId);
video.attachNetStream(stream);
}
public function connectToAudio(audioConnection:NetConnection, peerId:String):void {
//trace('Connecting to id: ' + id + ', stream: ' + peerId);
var astream = new NetStream(audioConnection, peerId);
astream.addEventListener(NetStatusEvent.NET_STATUS, onVideoStatus);
astream.play('audio-' + this.userId);
// todo: does this need a separate object?
video.attachNetStream(astream);
}
public function onVideoStatus(e:NetStatusEvent):void {
//trace('Member ' + peerId + ': ' + e.info.code);
}
public function remove():void {
removeChild(video);
stream.close();
//removeChild(rectangle);
}
function mover(e:*):void {
bar.visible = true;
t.visible = true;
}
function mout(e:*):void {
bar.visible = false;
t.visible = false;
}
}
}
|
1
sqwiggle/Self.as
Normal file
1
sqwiggle/Self.as
Normal file
@ -0,0 +1 @@
|
||||
package sqwiggle {
import flash.events.NetStatusEvent;
import flash.media.Camera;
import flash.net.NetConnection;
import flash.net.NetStream;
import sqwiggle.Member;
import flash.media.Microphone;
import flash.events.MouseEvent;
import fl.motion.MotionEvent;
public class Self extends Member {
var cam:Camera;
public function Self(userId:String, peerId:String) {
super(userId, peerId);
cam = Camera.getCamera();
cam.setQuality(0, 100);
}
public override function connectToAudio(audioConnection:NetConnection, peerId:String):void {
var stream = new NetStream(audioConnection, NetStream.DIRECT_CONNECTIONS);
stream.addEventListener(NetStatusEvent.NET_STATUS, onAudioStatus);
stream.attachAudio(Microphone.getMicrophone());
stream.publish('audio-' + this.userId);
}
public function onAudioStatus(e:NetStatusEvent):void {
// nothing here just yet
}
public override function connectToVideo(videoConnection:NetConnection):void {
//trace('Publishing to id ' + id + ', stream: ' + peerId);
var stream = new NetStream(videoConnection, NetStream.DIRECT_CONNECTIONS);
stream.addEventListener(NetStatusEvent.NET_STATUS, onVideoStatus);
stream.attachCamera(this.cam);
stream.publish(this.userId);
var client:Object = new Object();
client.onPeerConnect = function(caller:NetStream):Boolean {
trace('Callee connecting to stream: ' + caller.farID);
return true;
};
stream.client = client;
video.attachCamera(this.cam);
video.smoothing = true;
video.deblocking = 5;
}
}
}
|
1
sqwiggle/p2p.as
Normal file
1
sqwiggle/p2p.as
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user