Skip to main content
Inspiring
Oct 25, 2010 12:04 PM UTC
Answered

NetConnection.Connect.Rejected

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 is closed to new replies. Start a new post to keep the conversation going.
    SE_0208Correct answer
    Participating Frequently
    Oct 25, 2010 12:24 PM UTC

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

    11 replies

    SE_0208Correct answer
    Participating Frequently
    Oct 25, 2010 12:24 PM UTC

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

    Translate
    Inspiring
    Oct 26, 2010 8:26 AM UTC

    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.

    Translate
    Participating Frequently
    Oct 26, 2010 8:34 AM UTC

    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.

    Translate