1 Reply Latest reply on Jun 15, 2010 10:26 AM by foolish3737

    Noob - DynamicStreaming / Simple Demo

    foolish3737 Level 1

      Hello again,

      I'm following Almer Blank's tutorial on Dynamic Streaming (located here: http://labs.almerblank.com/2010/04/new-intro-to-adobe-osmf-videos/)

      His explanation is great but I think there might be a step missing (that or I'm lacking some prerequisite knowledge).

       

      Below is my code thus far. When I run it I do get a runtime error of "null object reference" for "compareStreamItems" in "org\osmf\net\DynamicStreamingResource.as:175".

       

      I'm having trouble pin-pointing where I'm at fault. My best guess is that something is funky with my vector setup. Anyone see any errors in the code I have implemented below?

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               initialize="init()">
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  import org.osmf.containers.MediaContainer;
                  import org.osmf.elements.VideoElement;
                  import org.osmf.layout.LayoutMetadata;
                  import org.osmf.media.DefaultMediaFactory;
                  import org.osmf.media.MediaPlayer;
                  import org.osmf.net.DynamicStreamingItem;
                  import org.osmf.net.DynamicStreamingResource;
                  import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader;
                  
                  private var mediaContainer:MediaContainer = new MediaContainer();
                  private var mediaFactory:DefaultMediaFactory = new DefaultMediaFactory();
                  private var videoElement:VideoElement;
                  private var mediaPlayer:MediaPlayer = new MediaPlayer();
                  
                  private var mediaResource:DynamicStreamingResource = new DynamicStreamingResource("rtmp://10.248.56.67/jfoley/dynamic/");
                  private var vector:Vector.<DynamicStreamingItem> = new Vector.<DynamicStreamingItem> (6);
                  
                  private function init():void
                  {
                      initMediaPlayer();
                      initDynamicStream();
                  }
                  
                  private function initMediaPlayer():void
                  {
                      mediaPlayerContainer.addChild(mediaContainer);
                  }
                  
                  private function initDynamicStream():void
                  {
                      vector[0] = new DynamicStreamingItem("mp4:BigBuckBunny_1330kbps", 1330000);
                      vector[1] = new DynamicStreamingItem("mp4:BigBuckBunny_1000kbps", 1000000);
                      vector[2] = new DynamicStreamingItem("mp4:BigBuckBunny_500kbps", 500000);
                      vector[3] = new DynamicStreamingItem("mp4:BigBuckBunny_280kbps", 280000);
                      
                      mediaResource.streamItems = vector;
                      videoElement = new VideoElement(mediaResource);
                      mediaPlayer.media = videoElement;
                      
                      mediaContainer.addMediaElement(videoElement);
                  }
              ]]>
          </fx:Script>
          <mx:UIComponent id="mediaPlayerContainer" />
      </s:Group>