Created
July 28, 2010 17:28
-
-
Save shamun/495435 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" | |
layout="absolute" | |
xmlns:cam="*" | |
width="100%" | |
> | |
<mx:HBox width="100%"> | |
<mx:HBox id="hb1" width="250"> | |
<mx:Button id="layer1" label="a" click="onSend(event);" /> | |
<mx:Button id="layer2" label="b" click="onRecv(event);" /> | |
</mx:HBox> | |
<mx:HBox id="hb2" > | |
<cam:webcam id="recorder" x="10" y="10" /> | |
<mx:Button id="recordToggle" click="onRecord( event );" label="Start Recording" x="106" y="278"/> | |
</mx:HBox> | |
<mx:HBox id="hb3" > | |
<cam:getdata id="recorderb" x="10" y="10" /> | |
<mx:Button id="recordToggleb" click="onRecordb( event );" label="Start Recording" x="106" y="278"/> | |
</mx:HBox> | |
</mx:HBox> | |
<mx:Script> | |
<![CDATA[ | |
import mx.controls.Alert; | |
// Its about layer 1 | |
private function onSend(e:Event):void { | |
recorder.init(); | |
} | |
// Its about layer 2 | |
private function onRecv(e:Event):void { | |
recorderb.init(); | |
} | |
private function onRecord( e:Event ):void { | |
if( recordToggle.label == "Start Recording" ) { | |
recorder.recordStream( true ); | |
recordToggle.label = "Stop Recording"; | |
} else { | |
recorder.recordStream( false ); | |
recordToggle.label = "Start Recording"; | |
} | |
} | |
private function onRecordb( e:Event ):void { | |
if( recordToggleb.label == "Start Recording" ) { | |
recorderb.recordStream( true ); | |
recordToggleb.label = "Stop Recording"; | |
} else { | |
recorderb.recordStream( false ); | |
recordToggleb.label = "Start Recording"; | |
} | |
} | |
]]> | |
</mx:Script> | |
</mx:Application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="320" height="240"> | |
<mx:Metadata> | |
[Event(name="recordStreamStart", type="events.CustomEventClass")] | |
[Event(name="recordStreamStop", type="events.CustomEventClass")] | |
</mx:Metadata> | |
<mx:Script> | |
<![CDATA[ | |
private var nc:NetConnection = new NetConnection(); | |
private var publish_ns:NetStream; | |
public function init():void { | |
nc.connect( "rtmp://localhost/test/" ); | |
nc.addEventListener( NetStatusEvent.NET_STATUS, onStatus ); | |
} | |
public function onStatus( e:Event ):void { | |
// now we can set the publish_ns connection to our 'nc' | |
publish_ns = new NetStream( nc ); | |
} | |
public function recordStream( isRecording:Boolean ):void { | |
if( isRecording ) { | |
recordStreamStart(); | |
} else { | |
recordStreamStop(); | |
} | |
} | |
private function recordStreamStart():void { | |
var fileName:String = "Flex_" ; | |
publish_ns.play( fileName ); | |
} | |
private function recordStreamStop():void { | |
publish_ns.close(); | |
} | |
]]> | |
</mx:Script> | |
<mx:VideoDisplay id="webCam" width="320" height="240" /> | |
</mx:Canvas> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="320" height="240"> | |
<mx:Metadata> | |
[Event(name="recordStreamStart", type="events.CustomEventClass")] | |
[Event(name="recordStreamStop", type="events.CustomEventClass")] | |
</mx:Metadata> | |
<mx:Script> | |
<![CDATA[ | |
//import flash.media.Camera; | |
private var nc:NetConnection = new NetConnection(); | |
private var publish_ns:NetStream; | |
//private var cam:Camera; | |
private var mic:Microphone; | |
public function init():void { | |
// this is what you'll change to point to different servers/applications | |
nc.connect( "rtmp://localhost/test/" ); | |
// get a reference to the audio stream that gets attached to the Netstream | |
mic = Microphone.getMicrophone(); | |
// you can't add a NetConnection to a NetStream until the NetConnection is | |
// actually connected. So we wait for a status event. | |
nc.addEventListener( NetStatusEvent.NET_STATUS, onStatus ); | |
} | |
public function onStatus( e:Event ):void { | |
// now we can set the publish_ns connection to our 'nc' | |
publish_ns = new NetStream( nc ); | |
// get the web cam video stream | |
//cam = Camera.getCamera(); | |
// here at polyGeek we are all about the best possible quality! | |
//cam.setQuality( 0, 100 ); | |
// attach the cam stream to our NetStream | |
//publish_ns.attachCamera( cam ); | |
// attach the audio | |
publish_ns.attachAudio( mic ); | |
// attach the cam stream to the VideoDisplay - id="webCam" - below | |
// so that we can see our web cam stream | |
//webCam.attachCamera( cam ); | |
} | |
public function recordStream( isRecording:Boolean ):void { | |
if( isRecording ) { | |
recordStreamStart(); | |
} else { | |
recordStreamStop(); | |
} | |
} | |
private function recordStreamStart():void { | |
// get a unique filename for the stream to be saved | |
//var fileName:String = "Flex_" + String( Math.random() ); | |
var fileName:String = "Flex_" ; | |
publish_ns.publish( fileName, "record" ); | |
} | |
private function recordStreamStop():void { | |
publish_ns.close(); | |
} | |
]]> | |
</mx:Script> | |
<mx:VideoDisplay id="webCam" width="320" height="240" /> | |
</mx:Canvas> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment