Results 1 to 2 of 2

Thread: VideoChat publish won't work when called directly

  1. #1
    Join Date
    Feb 2013

    Default VideoChat publish won't work when called directly

    Im working with Wowza Server to develop a little VideoChat. Im using the example they provide and tweaking it a little.

    Basically, Im just automatting (is that a word xD?) the process of conecting instead of writind the server address via FlashVars.

    The issue is when trying to broadcast. In the original example, the user sets a broadcast name and the broadcasting starts clicking a buttonm called by a onClick event

    doPublish.addEventListener(MouseEvent.CLICK, publish); // doPublish is a button, the
                                                          name of the function is publish()
    Instead of that, I just tried to call the broadcast function directly like this (it is the same function)

    connect.connectStr.text = "rtmp://" + address.toString() + "/videochat";
    connect.connectButton.addEventListener(MouseEvent.CLICK, doConnect);
    doPublish.addEventListener(MouseEvent.CLICK, publish);
    doSubscribe.addEventListener(MouseEvent.CLICK, subscribe);
    doConnect(); // Connects to the Wowza Server
    publish(); // Begins broadcasting
    subscribe(); //Receives the video feed from the other client
    For this to work, I removed the mouseEvent from the functions parameters

    AScript isn't really my thing, so a little help with this would be great xD

    Some more relevant code
    var nc:NetConnection = null;
    var camera:Camera;
    var microphone:Microphone;
    var nsPublish:NetStream = null;                      
    var nsPlay:NetStream = null;
    //Ext vars
    var address:Object = LoaderInfo(this.root.loaderInfo).parameters.address;
    var from:Object = LoaderInfo(this.root.loaderInfo).parameters.from;
    var to:Object = LoaderInfo(this.root.loaderInfo);
    function doConnect()
    // connect to the Wowza Media Server
        // create a connection to the wowza media server
        nc = new NetConnection();
        nc.connect("rtmp://" + address.toString() + "/videochat");
        // get status information from the NetConnection object
        nc.addEventListener(NetStatusEvent.NET_STATUS, ncOnStatus);
        connect.connectButton.label = "Disconnect";
        // uncomment this to monitor frame rate and buffer length
        //setInterval(updateStreamValues, 500);
    function subscribe()
        // create a new NetStream object for video playback
        nsPlay = new NetStream(nc);
        // trace the NetStream status information
        nsPlay.addEventListener(NetStatusEvent.NET_STATUS, nsPlayOnStatus);
        var nsPlayClientObj:Object = new Object();
        nsPlay.client = nsPlayClientObj;
        nsPlayClientObj.onMetaData = function(infoObject:Object) 
            // print debug information about the metaData
            for (var propName:String in infoObject)
                trace("  "+propName + " = " + infoObject[propName]);
        // set the buffer time to zero since it is chat
        nsPlay.bufferTime = 0;
        // subscribe to the named stream;
        // attach to the stream
        doSubscribe.label = 'Stop';
    function publish()
        // create a new NetStream object for video publishing
        nsPublish = new NetStream(nc); // printing strings, is here when the app stops executing code
        nsPublish.addEventListener(NetStatusEvent.NET_STATUS, nsPublishOnStatus);
        // set the buffer time to zero since it is chat
        nsPublish.bufferTime = 0;
        // publish the stream by name
        // add custom metadata to the stream
        var metaData:Object = new Object();
        metaData["description"] = "Chat using VideoChat example."
        nsPublish.send("@setDataFrame", "onMetaData", metaData);
        // attach the camera and microphone to the server
        doPublish.label = 'Stop';
        doSubscribe.enabled = true;

  2. #2
    Join Date
    Dec 2007


    You can remove doConnect and move those lines below the var declarations.

    Make sure you understand the role of the NetStatusEvent. You have to wait for "NetConnection.Connect.Success" notification before you can do anything with the NetStream.


Similar Threads

  1. multicast publish not able to make it to work
    By Necchi in forum AddOn: Other AddOns
    Replies: 1
    Last Post: 03-12-2013, 08:08 AM
  2. publish.password does not work
    By mustihi83 in forum General Forum
    Replies: 1
    Last Post: 04-16-2012, 03:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts