Skip to main content
Inspiring
October 25, 2010
Answered

NetConnection.Connect.Rejected

  • October 25, 2010
  • 1 reply
  • 3011 views

Hi,

I am newbie FMS.
Just i installed FMS 4.
created a swf..... the code is

var nc:NetConnection;
var ns:NetStream;
var nsPlayer:NetStream;
var vid:Video;
var vidPlayer:Video;
var cam:Camera;
var mic:Microphone;

nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.connect("rtmp://localhost/publishlive");

    publishCamera();
        displayPublishingVideo();
        displayPlaybackVideo();
       
function onNetStatus(event:NetStatusEvent):void{
    trace(event.info.code);
    txt.text = event.info.code;
    if(event.info.code == "NetConnection.Connect.Success"){
        publishCamera();
        displayPublishingVideo();
        displayPlaybackVideo();
    }
}  

function publishCamera() {
    cam = Camera.getCamera();
    mic = Microphone.getMicrophone();
    ns = new NetStream(nc);
    ns.attachCamera(cam);
    ns.attachAudio(mic);
    ns.publish("myCamera", "live");
}

function displayPublishingVideo():void {
    vid = new Video();
    vid.x = 10;
    vid.y = 10;
    vid.attachCamera(cam);
    addChild(vid); 
}

function displayPlaybackVideo():void{
    nsPlayer = new NetStream(nc);
    nsPlayer.play("myCamera");
    vidPlayer = new Video();
    vidPlayer.x = cam.width + 20;
    vidPlayer.y = 10;
    vidPlayer.attachNetStream(nsPlayer);
    addChild(vidPlayer);
}

I saved the file in the path "C:\Program Files\Adobe\Flash Media Server 4\webroot\publishlive"

When i execute the file from Firefox "http://localhost/publishlive/vr.swf"

It show me errors like

NetConnection.Connect.Rejected
NetConnection.Connect.Closed

Please help me to solve this.

thanks,
shanthi

    This topic has been closed for replies.
    Correct answer SE_0208

    Do you have application named "publishlive" in applications directory of FMS?

    1 reply

    SE_0208Correct answer
    Participating Frequently
    October 25, 2010

    Do you have application named "publishlive" in applications directory of FMS?

    Inspiring
    October 26, 2010

    Hi,

    Now the error is not coming.

    netStream connects successfully.

    But now I want to save the video and replay it.

    Please help me to do this.

    Here is my code....

    var nc:NetConnection;
    var ns:NetStream;
    var nsPlayer:NetStream;
    var vid:Video;
    var vidPlayer:Video;
    var cam:Camera;
    var mic:Microphone;

    nc = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
    nc.connect("rtmp://localhost/publishlive");

    function onNetStatus(event:NetStatusEvent):void{
        trace(event.info.code);
        if(event.info.code == "NetConnection.Connect.Success"){

       }

    function publishCamera(e:Event) {
        cam = Camera.getCamera();
        mic = Microphone.getMicrophone();
        ns = new NetStream(nc);
        ns.attachCamera(cam);
        ns.attachAudio(mic);
        ns.publish("myCamera", "live");
        displayPublishingVideo();
    }

    function displayPublishingVideo() {
        vid = new Video();
        vid.x = 10;
        vid.y = 10;
        vid.attachCamera(cam);
        addChild(vid); 
    }


    function displayPlaybackVideo(e:Event){
        nsPlayer = new NetStream(nc);
        nsPlayer.play("myCamera");
        vidPlayer = new Video();
        vidPlayer.x = cam.width + 20;
        vidPlayer.y = 10;
        vidPlayer.attachNetStream(nsPlayer);
        addChild(vidPlayer);
    }

    record_btn.addEventListener(MouseEvent.CLICK , publishCamera)
    play_btn.addEventListener(MouseEvent.CLICK , displayPlaybackVideo)

    Thanks,

    Shanthi.

    Participating Frequently
    October 26, 2010

    So what you are asking is to record the file and playback the recorded file - let me know if i did not get you right. So assuming i got you right, you just need to modify two lines of your code:

    Change ns.publish("myCamera", "live");  --> ns.publish("myCamera","record")

    and

    Change  nsPlayer.play("myCamera");  --> ns.play("myCamera",0,-1)

    Let me know if you run into issues.