• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

problem with sample code

Guest
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

Hi,I'm starting to study FMS3 and have it running locally in my machine. I've been using this book "Learning Flash Media Server 3" by William Sanders. In the second chapter there is code for a simple video recording application. Almost everything works except that when I press the record button I get this error message:

Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Publish.BadName
    at MinRecord/::checkConnect()

The code for the application follows, any ideas?

package
{
import fl.controls.Button;
import fl.controls.TextInput;
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import flash.events.MouseEvent;
import flash.events.Event;
//import flash.net.ObjectEncoding;
import flash.media.Camera;
import flash.media.Microphone;
import flash.media.Video;
public class MinRecord extends Sprite
{
private var nc:NetConnection;
private var ns:NetStream;
private var rtmpNow:String;
private var msg:Boolean;
private var cam:Camera;
private var mic:Microphone;
private var vid1:Video;
private var recordBtn:Button;
private var stopBtn:Button;
private var textInput:TextInput;
//Constructor
function MinRecord ()
{
//NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
nc=new NetConnection();
nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);
//rtmpNow="rtmp://192.168.0.1.101/vid2/recordings";
rtmpNow="rtmp:/vid2/recordings";
nc.connect (rtmpNow);
addMedia ();
addUI ();
recordBtn.addEventListener (MouseEvent.CLICK,startRecord);
stopBtn.addEventListener (MouseEvent.CLICK,stopRecord);
}
private function addMedia ():void
{
cam=Camera.getCamera();
cam.setMode (240,180,24);
cam.setQuality (0,90);
mic=Microphone.getMicrophone();
vid1=new Video(cam.width,cam.height);
vid1.attachCamera (cam);
addChild (vid1);
vid1.x=100;
vid1.y=50;
}
private function addUI ():void
{
recordBtn=new Button();
recordBtn.label="Record";
recordBtn.x=100;
recordBtn.y=50+(cam.height) +5;
recordBtn.width=70;
addChild (recordBtn);
stopBtn=new Button();
stopBtn.label="Stop Record";
stopBtn.x=recordBtn.x+85;
stopBtn.y=recordBtn.y;
stopBtn.width=75;
addChild (stopBtn);
textInput=new TextInput();
textInput.x=recordBtn.x;
textInput.y=recordBtn.y + 30;
addChild (textInput);
}
private function checkConnect (e:NetStatusEvent):void
{
msg=(e.info.code=="NetConnection.Connect.Success");
if (msg)
{
ns = new NetStream(nc);
}
}
private function startRecord (e:Event):void
{
if (ns)
{
recordBtn.label="Recording";
ns.attachAudio (mic);
ns.attachCamera (cam);
ns.publish (textInput.text,"record");
}
}
private function stopRecord (e:Event):void
{
recordBtn.label="Record";
ns.close ();
}
}
}

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Jul 01, 2009 Jul 01, 2009

I just glanced through the code fast and i dont see anything wrong in the code except I would have defined seperate handler for NetStream. Provided you are not publishing anythign previously any stream by same name there should not be any problem like Publish.BadName. Just a wild guess - are you putting any text in TextInput whcih is there in you UI to take name for stream - if you are not its takign blank string and hence you are gettign Publish.BadName - Sorry if my guess is wrong , you can wr

...

Votes

Translate

Translate
Adobe Employee ,
Jul 01, 2009 Jul 01, 2009

Copy link to clipboard

Copied

I just glanced through the code fast and i dont see anything wrong in the code except I would have defined seperate handler for NetStream. Provided you are not publishing anythign previously any stream by same name there should not be any problem like Publish.BadName. Just a wild guess - are you putting any text in TextInput whcih is there in you UI to take name for stream - if you are not its takign blank string and hence you are gettign Publish.BadName - Sorry if my guess is wrong , you can write back if its not the case.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2009 Jul 01, 2009

Copy link to clipboard

Copied

It was it, nailed it. thanks for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 01, 2009 Jul 01, 2009

Copy link to clipboard

Copied

LATEST

You are most welcome, can you mark question as answered , helps filtering out Answered and Unanswered questions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines