Copy link to clipboard
Copied
I am trying to built a multicast sample of video broadcast. with the trial version of AMS on my local system.
package {
import flash.display.MovieClip;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.net.NetStream;
import flash.media.Video;
import flash.media.Camera;
import flash.media.Microphone;
import flash.net.NetStreamPlayOptions;
import flash.net.NetStreamPlayTransitions;
import flash.net.GroupSpecifier;
import flash.net.NetGroup;
public class multicast extends MovieClip
{
var nc:NetConnection;
var ns:NetStream;
var vid:Video;
var vidPlayer:Video;
private var group:NetGroup;
public var devkey:String = "e4a84a9a6d0d3ce822fa4610-f148941b683a";
public function multicast()
{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.connect("rtmfp://192.168.1.167/multicast");
nc.client = {onBWDone:function():void{}};
}
private function onNetStatus(event:NetStatusEvent):void{
switch(event.info.code)
{
case "NetConnection.Connect.Success":
setupGroup();
break;
case "NetGroup.Connect.Success":
trace("Group has been generated");
break;
case "NetGroup.Posting.Notify":
break;
}
}
private function setupGroup():void
{
var groupspec:GroupSpecifier = new GroupSpecifier("myGroup");
groupspec.postingEnabled = true;
groupspec.ipMulticastMemberUpdatesEnabled = true;
groupspec.addIPMulticastAddress("192.168.1.167:30000");
ns = new NetStream(nc, groupspec.groupspecWithAuthorizations());
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
var cami:Camera = Camera.getCamera();
ns.attachCamera(cami);
ns.publish("multicast");
vid = new Video(cami.width, cami.height);
vid.x = 0;
vid.y = 0;
vid.attachCamera(cami);
addChild(vid);
}
}
}
Following is the error I am facing:
Error: Error #2154: The NetStream Object is invalid. This may be due to a failed NetConnection.
at flash.net::NetStream/invoke()
at flash.net::NetStream/attachCamera()
at multicast/setupGroup()
at multicast/onNetStatus()
Is there some problem with the server url. Please suggest.
Copy link to clipboard
Copied
You're not setting any NetConnection event listeners for potential connection issues. The error is just letting you know the NetConnection failed. Be sure any firewalls on the LAN server you're connecting to have rules to allow the connection as well.
As a symantics thing you should always add scope parameters to all class member variables (e.g. var nc:NetConnection; should be public/private/protected nc:NetConnection).
Lastly you should verify the camera is validly connected, just check if (cami != null)
Copy link to clipboard
Copied
Done with all the changes. No error is showing now but the streaming is also not working.
I am using flash player 11.2
AMS 5.1 multicast sample on the server side.
Copy link to clipboard
Copied
In contrast to errors, are there any positive traces? Like connection success, etc? Where the does the trail of success finally end? That's where you're going to need to investigate.
Copy link to clipboard
Copied
No, There is no any success or error message displayed.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now