0 Replies Latest reply on Jun 5, 2009 10:07 AM by TheNuttyNut

    FLVPlayback 2.5 - Exception thrown when switching from a dynamic stream to a normal stream

    TheNuttyNut Level 1

      For anyone who might come accross this and could use the information until the following bug is fixed.



      The FLVPlayback component iterates through a list of playlist items, some of which may be progressivly downloaded, streamed over a standard RTMP connection, and some taking advantage of Flash's new adaptive streaming technology. The problem is whenever I play an adaptive stream, if I update the source of the FLVPlayback component to an RTMP or regular progressive download url, an exception is thrown because the VideoPlayer assumes it is still dealing with a dynamic stream, which it is not.


      --- Exception Exerpt ---

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::_playDynamicStream()[fl\video\VideoP layer.as:4000]
          at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::_play()[fl\video\VideoPlayer.as:3981 ]
          at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::_setUpStream()[fl\video\VideoPlayer. as:4366]
          at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::_load()[fl\video\VideoPlayer.as:1287 ]
          at fl.video::VideoPlayer/play()[fl\video\VideoPlayer.as:1025]
          at fl.video::FLVPlayback/doContentPathConnect()[fl\video\FLVPlayback.as:4790]
          at fl.video::FLVPlayback/set source()[fl\video\FLVPlayback.as:2818]



      Further examination of the bug shows that the root of the problem lies in the function _createStream() inside the VideoPlayer class.


      --- Code Block ---

      flvplayback_internal function _createStream():void {
                  //ifdef DEBUG
                  _ns = null;
                  var theNS:NetStream;
                  if(_ncMgr.isDynamicStream == true){
                      theNS = new DynamicStream(_ncMgr.netConnection);
                  } else {
                      theNS = new NetStream(_ncMgr.netConnection);



      The problem here is _ncMgr.isDynamicStream always returns true once a dynamic stream has played, so Flash always creats a DynamicStream object for all subsequent streams. Trailing down the chain further, you will see that _isDynamicStream is set from the class NCManagerDynamicStream.as. You will see that _isDynamicStream is only set to true upon a successful connection, but no where in the code does it ever reset back to false.



      To fix this, I created a new INCManager class and overrided the close() function. Physically in my player, I call the close method on the video player before I set the source to the FLVPlayback component. This clears up the issue.


      --- Code Block ---

      // The new INCManager class. Overrides NCManagerDynamicStream

      public class CustomNCManagerDynamicStream extends NCManagerDynamicStream implements INCManager
           * Workaround FLVPlayback bug. VideoPlayer must be closed to cleanup
           * the dynamic stream member.
          public override function close() : void
              _isDynamicStream = false;



      // In the application, I must set the source and then close the video before each new source is assigned to the FLVPlayback component.

      VideoPlayer.iNCManagerClass = "path.to.CustomNCManagerDynamicStream";


      // Play the new source

      mPlayer.source = mCurrentPlaylistItem.MediaUrl;




      So this is a temp fix, but it would be nice if the FLVPlayback component fixed this. Or at least make sure this isn't an issue in the upcomming Strobe player.