3 Replies Latest reply on Feb 8, 2010 1:41 AM by screenFlavio

    SerialElement and CaptioningPugin

    screenFlavio

      Hi.

      I'd like to use the CaptioningPlugin with SerialElements.

      I modify the CaptioningSample as shown below.

      The first video start and captioning run correctly, but the second don't start.

      If I click on timebar, click and play buttons and so on, sometimes the second video and the second captioning work fine.

      can someone help me?

      Thanks.

       

                  private function init():void
                  {
                      mediaFactory = new MediaFactory();
                      pluginManager = new PluginManager(mediaFactory);
                     
                      loadPlugin("org.osmf.captioning.CaptioningPluginInfo");
                     
                      mediaPlayerWrapper.mediaPlayer.addEventListener(DisplayObjectEvent.MEDIA_SIZE_C HANGE, onMediaSizeChange);       
                      mediaPlayerWrapper.mediaPlayer.addEventListener(TimeEvent.DURATION_CHANGE, onDurationChange);   
                      mediaPlayerWrapper.mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onCurrentTimeChange);
                      mediaPlayerWrapper.mediaPlayer.addEventListener(SeekEvent.SEEK_END, onSeekEnd);
                      mediaPlayerWrapper.mediaPlayer.addEventListener(SeekEvent.SEEK_BEGIN, onSeekBegin);
                     
                      mediaPlayerWrapper.mediaPlayer.currentTimeUpdateInterval = DEFAULT_PROGRESS_DELAY;
      //FD modify begin                               
                      var serialElement:SerialElement = new SerialElement();
                      serialElement.addChild(loadMedia(new URLResource(new URL(REMOTE_PROGRESSIVE))));
                      serialElement.addChild(loadMedia(new URLResource(new FMSURL(REMOTE_STREAM))));
      //FD modify end
                      sliderDragging = false;
                      waitForSeek = false;
                      captioningEnabled = true;
                     
      //FD modify begin
                      mediaPlayerWrapper.element = serialElement;
                      enablePlayerControls(true);
      //FD modify end               
                  }

       

      //FD modify loadMedia: return a MediaElement           
                  private function loadMedia(resource:URLResource):MediaElement
                  {
                      //var resource:URLResource = new URLResource(new FMSURL(url));
                 
                      // Assign to the resource the metadata that indicates that it should have a Timed Text
                      // document applied (and include the URL of that document).
                      var kvFacet:KeyValueFacet = new KeyValueFacet(CaptioningPluginInfo.CAPTIONING_METADATA_NAMESPACE);
                                                     
                      kvFacet.addValue(new ObjectIdentifier(CaptioningPluginInfo.CAPTIONING_METADATA_KEY_URI),
                                          CAPTION_URL);
                      resource.metadata.addFacet(kvFacet);

       

                      var netLoader:NetLoader = new NetLoader();

       

                      mediaFactory.addMediaInfo(new MediaInfo("org.osmf.video", netLoader, createVideoElement));
                      var mediaElement:MediaElement = mediaFactory.createMediaElement(resource);

       

                      // Listen for traits to be added, so we can adjust the UI. For example, enable the seek bar
                      // when ISeekable is added
                      mediaElement.addEventListener(MediaElementEvent.TRAIT_ADD, onTraitAdd);
                     
                      // Listen for metadata to be added so we can add any desired event listeners on any
                      // metadata facets we care about. For example, the temporalFacet.
                      mediaElement.metadata.addEventListener(MetadataEvent.FACET_ADD, onFacetAdd);
                     
                      // Listen for metadata to be removed so we remove an event listeners
                      mediaElement.metadata.addEventListener(MetadataEvent.FACET_REMOVE, onFacetRemove);

       

                      mediaElement.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError, false, 0, true);
                                     
                      return mediaElement;
                  }