D_C
D_C

Reputation: 11

Capture video/audio from webcam, view it and send as a file to server (ex. youtube) in flash/actionscript

I'm new in AS and trying create util such Youtube's "My webcam". Here's a part of my code:

var camera:Camera = Camera.getCamera(cameraIndex.toString());
VideoDisplay.attachCamera(camera); //view yourself
var mic:Microphone = Microphone.getMicrophone(0);

video = new Video();
netconnection = new NetConnection;
netconnection.connect(null);

netstream = new NetStream(netconnection);
netstream.attachAudio(mic);
netstream.attachCamera(camera);

video.attachNetStream(netstream); //store video

Can't attach video object or stream to spark.components.VideoPlayer to view video and don't know how to convert video to flv contents for sending in POST form.

Any thoughts? Thanks a lot!

Upvotes: 1

Views: 1630

Answers (1)

Holobyte
Holobyte

Reputation: 11

I retrieved this from the O'Relly Learning AS3 book.

1.  var vidConnection:NetConnection = new NetConnection(); 
2.  vidConnection.connect(null); 

4.  var vidStream:NetStream = new NetStream(vidConnection); 

6.  var vid:Video = new Video(); 
7.  addChild(vid); 
8.  vid.attachNetStream(vidStream); 

10. vidStream.play("video_name.flv");

Upvotes: 1

Related Questions