0 Replies Latest reply on May 5, 2011 12:32 AM by Maria Sigal

    is there  any way to use osmf plugin with videodisplay component?

    Maria Sigal Level 1


      i use flex sdk hero (17689 build)

      i want to use OSMF plugin for the  captioning. i created object of media element with metadata for captioning plugin so  eventually i get object of CaptioningProxyElement type from mediaFactory ,  than i pass it to the source of videoDisplay> in source setter of videoDisplay setUpSource()  is called . in setUpSource  the type of source is checked and videoElement is created and assinged to videoPlayer( of type MediaPlayer) according  to the source type.The problem is that  my source is of type  CaptioningProxyElement (extended from MediaPlayer) so setUpSource ignores it , eventually not assining it to videoPlayer.  i can't extend VideoDispay and override source either , since videoPlayer is of type mx_internal , it's not accessible .

      thanks in advance.

      private function setUpSource():void
              // clean up any listeners from the old source, especially if we
              // are in the processing of loading that video file up
              // if was playing a previous video, let's remove it now
              if (videoPlayer.media && videoContainer.containsMediaElement(videoPlayer.media))
              var videoElement:org.osmf.media.MediaElement = null;
              // check for 4 cases: streaming video, progressive download,
              // an IMediaResource, or a VideoElement. 
              // The latter 2 are undocumented but allowed for flexibility until we
              // can support OSMF better after they ship OSMF 1.0.  At that point, support
              // for a source as an IMediaResource or a VideoElement may be removed.
              if (source is DynamicStreamingVideoSource)
                  // the streaming video case.
                  // build up a DynamicStreamingResource to pass in to OSMF
                  var streamingSource:DynamicStreamingVideoSource = source as DynamicStreamingVideoSource;
                  var dsr:DynamicStreamingResource;
                  // check for two cases for host: String and URL.
                  // Technically, we only support URL, but we secretly allow
                  // them to send in an OSMF URL or FMSURL here to help resolve any ambiguity
                  // around serverName vs. streamName.
                  if (streamingSource.host is String)
                      dsr = new DynamicStreamingResource(streamingSource.host as String,
                  else if (streamingSource.host is URL)
                      dsr = new DynamicStreamingResource(URL(streamingSource.host).host,
                  if (dsr)
                      var n:int = streamingSource.streamItems.length;
                      var item:DynamicStreamingVideoItem;
                      var dsi:DynamicStreamingItem;
                      var streamItems:Vector.<DynamicStreamingItem> = new Vector.<DynamicStreamingItem>(n);
                      for (var i:int = 0; i < n; i++)
                          item = streamingSource.streamItems[i];
                          dsi = new DynamicStreamingItem(item.streamName, item.bitrate);
                          streamItems[i] = dsi;
                      dsr.streamItems = streamItems;
                      dsr.initialIndex = streamingSource.initialIndex;
                      // add video type metadata so if the URL is ambiguous, OSMF will
                      // know what type of file we're trying to connect to
                      dsr.mediaType = MediaType.VIDEO;
                      videoElement = new org.osmf.elements.VideoElement(dsr, new RTMPDynamicStreamingNetLoader());
              else if (source is String)
                  var urlResource:URLResource = new URLResource(source as String);
                  videoElement = mediaFactory.createMediaElement(urlResource);
                  // If the url could not be resolved to a media element then try
                  // telling osmf the media is a video and try again.
                  // We do not specify the media type as video the first time,
                  // so we can have the chance to play audio.
                  if (videoElement == null)
                      urlResource.mediaType = MediaType.VIDEO;
                      videoElement = mediaFactory.createMediaElement(urlResource);               
              else if (source is MediaResourceBase)
                  videoElement = mediaFactory.createMediaElement(MediaResourceBase(source));
              else if (source is org.osmf.elements.VideoElement)
                  videoElement = source as org.osmf.elements.VideoElement;
              // reset the visibilityPausedTheVideo flag
              playTheVideoOnVisible = true;
              // set up videoPlayer.autoPlay based on whether this.autoPlay is
              // set and whether we are visible and the other typical conditions.
              changePlayback(false, false);
              // if we're not going to autoPlay (or couldn't autoPlay because
              // we're hidden or for some other reason), but we need to seek
              // to the first frame, then we have to do this on our own
              // by using our load() method.
              if ((!autoPlay || !shouldBePlaying) && autoDisplayFirstFrame)
              // set videoPlayer's element to the newly constructed VideoElement
              // set the newly constructed videoElement's gateway to be the videoGateway
              videoPlayer.media = videoElement;
              if (videoElement)


                  if (videoElement.getMetadata(LayoutMetadata.LAYOUT_NAMESPACE) == null)
                      var layout:LayoutMetadata = new LayoutMetadata();
                      layout.scaleMode = scaleMode;
                      layout.verticalAlign = VerticalAlign.MIDDLE;
                      layout.horizontalAlign = HorizontalAlign.CENTER;
                      layout.percentWidth = 100;
                      layout.percentHeight = 100;
                      videoElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);


                  if (videoElement && !videoContainer.containsMediaElement(videoElement) )
                  // if our source is null, let's invalidateSize() here.
                  // if it's a bad source, we'll get a playbackError and invalidate
                  // the size down there.  If it's a good source, we'll get a
                  // dimensionChange event and invalidate the size in there.