5 Replies Latest reply on Sep 27, 2010 4:18 AM by greggdilorenzo2010

    SerialElement not seekable, as VideoElements are not loaded yet

    Wout Lemmens Level 1

      Hi,

       

      I've got an issue, quite clear why it isn't working, but I haven't got a clue how to resolve it. For the record, I'm using the sprint 8 framework code.

       

      What I would like is to have a SerialElement containing some VideoElements (from different rtmp sources), and being able to jump to each VideoElement by using Cue Points.

       

      Currently when playing the SerialElement from the start to the end, it works all fine. When I have e.g. three VideoElements in the SerialElement, jumping (using seek) to the second element, and after that jumping to the third element works fine as well.

      But jumping from the first to the third element fails. It plays the second element instead.

       

      What I see is that when I call mediaPlayer.seek(time) as result of wanting to jump from the first element to the third, the SerialSeekTrait.doSeek method cannot get the SEEK trait of the child in which the time to jump to is situated.

       

                      // Now the composite does the seek into another child, where the destiny of the seek is.
                      childSeekTrait = serialSeek.toChild.getTrait(MediaTraitType.SEEK) as SeekTrait;

       

      This is the result of the fact the third VideoElement to jump to is not loaded yet, and thus the SEEK trait has not been added yet.

       

      When jumping from the first to the second VideoElement, the second element is loaded 'just in time', making the SEEK trait available. But when trying to jump from the first to the third, only the second element is loaded. Consequence: the SEEK trait of the third element is not added and the seek fails.

       

      Any thoughts on this?

       

      Wout

        • 1. Re: SerialElement not seekable, as VideoElements are not loaded yet
          bringrags Level 4

          You're right that the children of SerialElement are loaded "just in time".  To override this behavior, you can forcibly load all of them upfront (or whenever you want).  For an example of how to do this, see the "Serial Composition (Preloaded)" example here:

           

          http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/framework/ExamplePlayer /org/osmf/examples/AllExamples.as

          • 2. Re: SerialElement not seekable, as VideoElements are not loaded yet
            Wout Lemmens Level 1

            I overlooked that example, but came up with manual loading myself. Unfortunately it does not really fit my needs.

             

            What I got as an answer on a previous question, was that I can set the defaultDuration of an VideoElement before adding it to a SerialElement, and then the total duration is displayed correctly when calling play on the mediaplayer. It worked. But when I preload the video's, that does not work anymore.

             

            To demonstrate I changed the example you referred to: I added two subclips of each 10 seconds (so I know the duration even with streaming video), and added these to the SerialElement. When the preload is commented, the duration works correctly. When uncommented the duration initially is 10 seconds, and gets updated to 20 seconds when the second video is reached.

             

            examples.push
                ( new Example
                    (     "Serial Composition (Preloaded) - customized"
                    ,     ""
                      ,      function():MediaElement
                             {
                                 function preload(mediaElement:MediaElement):void
                                 {
                                var loadTrait:LoadTrait = videoElement.getTrait(MediaTraitType.LOAD) as LoadTrait;
                                loadTrait.addEventListener(LoadEvent.LOAD_STATE_CHANGE, onLoadStateChange);
                                loadTrait.load();
                               
                                function onLoadStateChange(event:LoadEvent):void
                                {
                                    if (event.loadState == LoadState.READY)
                                    {
                                        loadTrait.removeEventListener(LoadEvent.LOAD_STATE_CHANGE, onLoadStateChange);
                                       
                                        var playTrait:PlayTrait = mediaElement.getTrait(MediaTraitType.PLAY) as PlayTrait;
                                        playTrait.play();
                                        playTrait.pause();
                                    }
                                }
                                 }
                                
                            var serialElement:SerialElement = new SerialElement();
                           
                           
                            var kvFacet:KeyValueFacet = new KeyValueFacet(MetadataNamespaces.SUBCLIP_METADATA);
                            kvFacet.addValue(MetadataNamespaces.SUBCLIP_START_ID, 0);
                            kvFacet.addValue(MetadataNamespaces.SUBCLIP_END_ID, 10);
                            var resource:URLResource = new URLResource(new URL(REMOTE_STREAM));
                            resource.metadata.addFacet(kvFacet);

             

                            var videoElement:VideoElement = new VideoElement(new NetLoader(), resource);
                            videoElement.defaultDuration = 10;
                            preload(videoElement);
                           
                            serialElement.addChild(videoElement);
                           
                           
                           
                            kvFacet = new KeyValueFacet(MetadataNamespaces.SUBCLIP_METADATA);
                            kvFacet.addValue(MetadataNamespaces.SUBCLIP_START_ID, 0);
                            kvFacet.addValue(MetadataNamespaces.SUBCLIP_END_ID, 10);
                            resource = new URLResource(new URL(REMOTE_STREAM));
                            resource.metadata.addFacet(kvFacet);

             

                            videoElement = new VideoElement(new NetLoader(), resource);
                            videoElement.defaultDuration = 10;
                            preload(videoElement);
                           
                            serialElement.addChild(videoElement);
                            return serialElement;
                             }
                      )
                );

            • 3. Re: SerialElement not seekable, as VideoElements are not loaded yet
              bringrags Level 4

              This is a bug, and my suspicion is that there's an inconsistent set of events being dispatched by the TimeTrait's trait resolver.  (Trait resolvers are the low-level pieces responsible for handling things like defaultDuration).  Here's an extremely simplified case that demonstrates the same problem:

               

                                          var serialElement:SerialElement = new SerialElement();
                                         
                                          var videoElement:VideoElement = new VideoElement(new NetLoader(), new URLResource(new URL(REMOTE_STREAM)));
                                          videoElement.defaultDuration = 10;
                                          serialElement.addChild(videoElement);
                                         
                                          videoElement = new VideoElement(new NetLoader(), new URLResource(new URL(REMOTE_PROGRESSIVE)));
                                          videoElement.defaultDuration = 10;
                                          serialElement.addChild(videoElement);
                                         
                                          return serialElement;

               

              When you click on this example in ExamplePlayer, you'll see the duration go from 20 to 10.  It ought to stay at 20.

               

              Can you file a bug and reference this thread?  Thanks!

              • 4. Re: SerialElement not seekable, as VideoElements are not loaded yet
                Wout Lemmens Level 1

                Reported it: https://bugs.adobe.com/jira/browse/FM-348

                 

                When I find some kind of workaround (if any exists), I'll post it here. Or maybe others might have suggestions.

                 

                Grtz.

                Wout