Skip to main content
Inspiring
January 13, 2010
Answered

FLVPlayback Component's ncMgr.netConnection is null when connecting to my Flash Media Server?

  • January 13, 2010
  • 1 reply
  • 1386 views

Hi all,

I'm trying to troubleshoot a Flash Media Server working with a little video playback application I wrote a few years ago that has suddenly stopped working.  I'm using CS3/Actionscript 3.  My app uses the FLVPlayback Component, and was working well last time I checked.  I recevied a report that the videos stopped working, and have been looking into it.  I figured I'd add a bunch of event listeners to the FLVPlayback's ncMgr.netConnection so I could get debug info on things like io errors, net status, etc.  The problem I'm running into is that the netConnection is null when I set it to anything on my Flash Media Server, and adding any event listeners to this netConnection throws errors.  Here's what I've tried so far:

Playback of a local FLV file works fine.  In the FLVPlayback documentation, I found an example and stole the URL of the stream they were using in the example, and that works fine, although it is an HTTP protocol stream rather than RTMP.  Any attempt to access FLV files on my Media Server, which has worked fine in the past, basically cause the FLVPlayback object to sit and hang in "buffering" mode and never progresses beyond this point.  The netConnection object in this case is null.

Here's my code:

        public function FLVPlayer(){  // CLASS CONSTRUCTOR   
            
             var v:FLVPlayback = new FLVPlayback(); // INSTANTIATE FLVPLAYBACK COMPONENT
             v.width=425;
             v.height=319;
             v.skin = "SkinUnderPlayStopSeekFullVol.swf";   

            v.source = get_which_video();   
             trace('video source: ' + v.source);
             addChild(v);                       
             trace('netconnection: ' + v.ncMgr.netConnection);
         }

        private function get_which_video():String{
             var v_src:String ;

            v_src = "rtmp://flash.wa.gov/CAA_legislativeDay/caa_2007_reception_CBR.flv"; // URI FOR FILE ON FLASH MEDIA SERVER
            v_src = "caa_2007_governor_CBR.flv"; // URI FOR LOCAL FILE
            v_src = "http://www.helpexamples.com/flash/video/caption_video.flv"; // URI FROM FLVPLAYBACK EXAMPLE ON ADOBE.COM


            return v_src;           
        }

You can see that v_src is set 3 times in the get_which_video function.  By commenting out 2 and leaving one, I get the following results in my traces:

v_src = "rtmp://...":

video source: rtmp://flash.wa.gov/CAA_legislativeDay/caa_2007_reception_CBR.flv
netconnection: null

v_src = "caa_2007_governor_CBR.flv":

video source: caa_2007_governor_CBR.flv
netconnection: [object NetConnection]

v_src = "http://...":

video source: http://www.helpexamples.com/flash/video/caption_video.flv
netconnection: [object NetConnection]

Can anyone explain to me what's going on?  Again the purpose of this is to troubleshoot the video streaming from the Flash Media Server, and it seems like there is no netconnection to the server being created.  Does this mean that the server is not working, or is there a problem with the way I'm trying to access the content on the server?  This was all working fine before, and I have set up the server-side application .ASC files and such to allow things to work fine on the server end.  Any advice or suggestions are greatly appreciated.

    This topic has been closed for replies.
    Correct answer Robert Reinhardt

    Try:

    fl.video.VideoEvent.STATE_CHANGE

    The docs are actually a bit incorrect with that event--it's not just playback events. You can see all of the states here in the VideoState class:

    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/VideoState.html

    VideoState.CONNECTION_ERROR will be dispatched if there's a problem with the NetConnection URL.

    HTH.

    -Robert

    1 reply

    Inspiring
    January 13, 2010

    NetConnection will be null until the source is specified and a connection has been made. Better to add an event listener on the FLVPlayback to detect the problems. Take a look at the events for the FLVPlayback class in the AS3 Language Ref, and listen for the one that's related to connection errors.

    HTH.

    -Robert

    --

    Robert Reinhardt

    Creator, videoRx.com

    Author, Flash Bible series and Video for Adobe Flash CS4 Professional Studio Techniques

    http://blogs.flashsupport.com/robert

    Inspiring
    January 13, 2010

    Thanks for the help!  I'm looking at the FLVPlayback documentation at:

    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html

    And I don't see any events that correspond to anything having to do with the network.  This is why I bothered to drill down to the component's ncMgr.netConnection rather than try to deal with the component at the top level.  Am I missing something here, are there more events that the FLVPlayback component can throw that I'm not seeing on the livedocs listed above?  The only error event I see listed there is the SkinErrorEvent.  I've also read the details about the load() and play() methods to make sure that those don't do anything more than I would expect.

    Robert ReinhardtCorrect answer
    Inspiring
    January 13, 2010

    Try:

    fl.video.VideoEvent.STATE_CHANGE

    The docs are actually a bit incorrect with that event--it's not just playback events. You can see all of the states here in the VideoState class:

    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/VideoState.html

    VideoState.CONNECTION_ERROR will be dispatched if there's a problem with the NetConnection URL.

    HTH.

    -Robert