A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: [RESOLVED] AS3 Steam RTMP LIVE video WITHOUT FLVPlayback Component

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    85

    resolved [RESOLVED] AS3 Steam RTMP LIVE video WITHOUT FLVPlayback Component

    First off, I apologize if any of this comes off snobby. I've spent the past 2 days scouring Google and dozens (easily over 100) websites trying to find an answer to something that people do every day! I am absolutely disgusted that this info is not available anywhere online.

    I can play my live rtmp (fms) stream through the FLVPlayback component without any problems. I even figured out how to make my own player in AS2. But I still can not get a LIVE player in AS3. I keep getting "onMetaData", "Async" and "onBWDone" errors in varying combinations.

    Can someone, please find it in their heart to provide me with the appropriate code? Every single tutorial online is either AS2 or is for flvplayback (nc.connect goes to null).

    Here is my working AS2 code. I have a "linked video" thing from the library named "live_feed" on the stage.

    Code:
    //connect to the Flash Media Server
    client_nc = new NetConnection();
    client_nc.connect("rtmp://12.34.56.789/live/");
    
    //bring in video/audio
    in_ns = new NetStream(client_nc);
    in_ns.play("livestream");
    
    live_feed.attachVideo(in_ns);
    live_feed.attachAudio(in_ns);

  2. #2
    Member
    Join Date
    Aug 2008
    Posts
    85
    Here is my AS3 code which works, but Flash CS4 outputs this error.

    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
    at Untitled_fla::MainTimeline/frame1()


    Code:
    var nc:NetConnection = new NetConnection();
    nc.connect("rtmp://12.34.56.789/live/");
    
    function netstat(stats:NetStatusEvent) {
    	//trace(stats.info.code);
    }
    
    nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
    
    function onNetStatus(event:NetStatusEvent):void {
    	if (event.info.code=="NetConnection.Connect.Success") {
    		var ns:NetStream=new NetStream(nc);
    
    		var vid:Video=new Video(320,240);
    		this.addChild(vid);
    
    		vid.attachNetStream(ns);
    
    		ns.play("livestream");
    		ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
    		ns.client=this;
    	}
    }

  3. #3
    Member
    Join Date
    Aug 2008
    Posts
    85
    Here is YET ANOTHER (AS3) attempt of mine, which works, but yet again outputs a (different) error. This one involves a "linked video" thing from the library named myVideo on the stage.

    Error #2095: flash.net.NetStream was unable to invoke callback onMetaData.

    Code:
    var nc:NetConnection = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
    nc.connect("rtmp://12.34.56.789/live/");
    
    
    function onNetStatus(event:NetStatusEvent):void {
    	if (event.info.code=="NetConnection.Connect.Success") {
    		var ns:NetStream=new NetStream(nc);
    		myVideo.attachNetStream(ns);
    		ns.play("livestream");
    		ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
    	}
    }
    
    function asyncErrorHandler(event:AsyncErrorEvent):void {
    	trace(event.text);
    }
    
    nc.client=this;

  4. #4
    Member
    Join Date
    Aug 2008
    Posts
    85
    To the top...

  5. #5
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    try adding this, just before myVideo.attachNetStream(ns);
    PHP Code:
    meta = new Object();
    ns.client meta;
    meta.onMetaData metaHandler
    Don't forget to make the variable meta at the top of your code!
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  6. #6
    Member
    Join Date
    Aug 2008
    Posts
    85
    How do I make the variable? I've tried and I still can't get it to work. I have no idea what type of variable it is, so I tried different things from Google searches.

    var meta:Object = new Object();

  7. #7
    Member
    Join Date
    Aug 2008
    Posts
    85
    Instead of trying to fix this code, can anyone give me the entire neccessary code to play a live rtmp stream? Every single tutorial online is about how to play a flv file. There is not a single tutorial about how to connect to FMS and play the stream, without errors.. at least that I could find in over 100 different websites and attempts.

    I'd like to plug in the 2 parts of the rtmp url and have it play, without any errors whatsoever. Then, I will focus on adding custom play/stop/volume/fullscreen buttons.

  8. #8
    Member
    Join Date
    Aug 2008
    Posts
    85
    I found a tutorial on fmsguru.com and came up with this code. It works exactly the same as in the tutorial and works fine, except the following error. It seems that this error only appears when previewing the file in Flash CS4 (the authoring program). Regardless, it is very annoying, so if anyone knows how to get rid of the error, please share.

    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
    at Untitled_fla::MainTimeline/frame1()


    Code:
    var nc:NetConnection;
    var ns:NetStream;
    var liveVideo:Video;
    
    nc = new NetConnection();
    
    nc.addEventListener(NetStatusEvent.NET_STATUS, onConnectionStatus);
    
    function onConnectionStatus(e:NetStatusEvent):void {
    	if (e.info.code=="NetConnection.Connect.Success") {
    		getTheStream();
    	}
    }
    
    function getTheStream():void {
    	ns=new NetStream(nc);
    
    	ns.client=this;
    	liveVideo.attachNetStream(ns);
    
    	ns.play("livestream");
    }
    
    function onMetaData(info:Object):void {
    	//do nothing
    }
    
    nc.connect("rtmp://12.34.56.789/live");

  9. #9
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Well, it appears the onBWDone is not in the flash.net.NetConnection package (as the error says), and I've found this in a guys code:
    PHP Code:
    NetConnection.prototype.onBWDone = function(p_bw) {
    trace("onBWDone: "+p_bw);
    }; 
    link

    Is a dirty way of doing this, since using the prototype property kind of messes with the NetConnection class, but I think it's worth a try
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  10. #10
    Banned
    Join Date
    Oct 2008
    Posts
    74
    Quote Originally Posted by sufire View Post
    I can play my live rtmp (fms) stream through the FLVPlayback component without any problems. I even figured out how to make my own player in AS2. But I still can not get a LIVE player in AS3. I keep getting "onMetaData", "Async" and "onBWDone" errors in varying combinations.

    Can someone, please find it in their heart to provide me with the appropriate code? Every single tutorial online is either AS2 or is for flvplayback (nc.connect goes to null).
    I think this tutorial will be useful, which shows how to use FLVPlayback component to make live RTMP stream receiver - http://www.flashkit.com/tutorials/Ti...1619/index.php

  11. #11
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Quote Originally Posted by Stephanee View Post
    I think this tutorial will be useful, which shows how to use FLVPlayback component to make live RTMP stream receiver - http://www.flashkit.com/tutorials/Ti...1619/index.php
    It appears sufire doesn't want to use a FLVPlayback component, just check the titel of the thread
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  12. #12
    Member
    Join Date
    Aug 2008
    Posts
    85
    Thanks Florian! Works great! I am a little nervous about using that code, simply because I don't like to use code unless I understand exactly what it does, but ultimately it makes that annoying error go away so I'm happy.

    It does return "onBWDone: undefined" though, so I commented out the trace.

    I think I read somewhere that onBWDone is not part of ActionScript 3.0, but is part of Flash Media Server. I believe the server (by default, can be disabled) calls this function. I find it odd that Adobe would release the server with the code without updating AS3 to be able to handle it.

  13. #13
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Good thing this error got fixed though

    Setting a prototype function is as writing classes and adding functions to a class, with the only difference that you're adding to a class that is already written.
    So no major changing or messing with the code occurs, but it's just not a very clean method..
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  14. #14
    Junior Member
    Join Date
    Sep 2011
    Posts
    6
    Quote Originally Posted by sufire View Post
    I found a tutorial on fmsguru.com and came up with this code. It works exactly the same as in the tutorial and works fine, except the following error. It seems that this error only appears when previewing the file in Flash CS4 (the authoring program). Regardless, it is very annoying, so if anyone knows how to get rid of the error, please share.

    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
    at Untitled_fla::MainTimeline/frame1()


    Code:
    var nc:NetConnection;
    var ns:NetStream;
    var liveVideo:Video;
    
    nc = new NetConnection();
    
    nc.addEventListener(NetStatusEvent.NET_STATUS, onConnectionStatus);
    
    function onConnectionStatus(e:NetStatusEvent):void {
    	if (e.info.code=="NetConnection.Connect.Success") {
    		getTheStream();
    	}
    }
    
    function getTheStream():void {
    	ns=new NetStream(nc);
    
    	ns.client=this;
    	liveVideo.attachNetStream(ns);
    
    	ns.play("livestream");
    }
    
    function onMetaData(info:Object):void {
    	//do nothing
    }
    
    nc.connect("rtmp://12.34.56.789/live");
    How can i add a pause and play button to this script?

  15. #15
    Junior Member
    Join Date
    Mar 2012
    Posts
    1

    Some Problem with this or is it me?

    After using the above script with the same FME and FMS set-up I to get the same messages. However it does play but when I test the control it stops playing after about 3 min. I published into an swf and it looks great but just stops after appx 3 min. Is there a setting somewhere I missed or maybe the error caused the trigger. Any Ideas? Thanks!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center