Skip to main content
April 16, 2010
Question

Creating a simple videodisplay of fms stream: Help

  • April 16, 2010
  • 1 reply
  • 3279 views

Hi!

The documentation for FMIS is in my mind poor. All I want is to display a videostream from my server in an swf.

I've manage to display the file using http or local but rtmp seems to be another ballgame. The file play using rtmp using jwplayer.

So far I have this code:

var video:Video = new Video(550,310);
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect("rmtp://myserver/myapp");
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
function onStatusEvent(stat:Object):void {
     trace(stat.info.code);
}
var meta:Object = new Object();
meta.onMetaData = function()
{
trace(meta.duration);
};
ns.client = meta;
video.attachNetStream(ns);
ns.play("mymovie.mov");

I get this in the Flash Output panel:

ArgumentError: Error #2004: One of the parameters is invalid.
    at flash.net::NetConnection/connect()
    at my_fla::MainTimeline/my_fla::frame1()

Please help!

Thanks

    This topic has been closed for replies.

    1 reply

    April 16, 2010

    Hi,

    Could modify the statement

    nc.connect("rmtp://myserver/myapp");

    to

    nc.connect("rtmp://myserver/myapp");

    and also you need to mention mp4: while playing it like:

    ns.play("mp4:mymovie.mov");

    Please make sure you have a Flash Player with version 9.0.115.0 or above.

    Thanks

    Mamata

    April 16, 2010

    Thanks Mamata Karna!

    I've made those corrections but the file will still not display. I now get:

    ArgumentError: Error #2126: NetConnection object must be connected.
        at flash.net::NetStream/flash.net:NetStream::construct()
        at flash.net::NetStream$iinit()
        at test_display_rtmp_fla::MainTimeline/test_display_rtmp_fla::frame1()

    My code:

    var video:Video = new Video(550,310);
    addChild(video);
    var nc:NetConnection = new NetConnection();
    nc.connect("rtmp://myserver/myapp");
    var ns:NetStream = new NetStream(nc);
    ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
    function onStatusEvent(stat:Object):void {
         trace(stat.info.code);    
    }
    var meta:Object = new Object();
    meta.onMetaData = function()
    {
         trace(meta.duration);
    };
    ns.client = meta;
    video.attachNetStream(ns);
    ns.play("mp4:mymovie.mov");

    And "yes" I have FP 10 something installed

    April 16, 2010

    I still can't see my video and now I have NO help from the Output panel. I've modified the code so everything seems to work EXCEPT the video showing up

    var video:Video = new Video(550,310);
    addChild(video);
    var nc:NetConnection = new NetConnection();
    nc.connect("rtmp://myserver/myapp/");
    var meta:Object = new Object();
    nc.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
    function onStatusEvent(stat:Object):void {
         trace(stat.info.code);
         if (stat.info.code == "NetConnection.Connect.Success") {
              var ns:NetStream = new NetStream(nc);
              ns.client = meta;
              video.attachNetStream(ns);
              ns.play("mp4:mymovie.mov");
              trace("Trying");
         }
    }

    meta.onMetaData = function()
    {
         trace("Clip duration: "+meta.duration);
    };

    Output:

    NetConnection.Connect.Success
    Trying
    Clip duration: undefined


    Is someone able to figure out where I'm going wrong?