2 Replies Latest reply on Feb 8, 2010 2:14 AM by jcastelain

    "Swapping" media elements, in a parallel element

    jcastelain Level 1

      Hi All,

       

      I'm not sure at all if this is the way I'm supposed to do this,but the goal is to play 2 videos "synchronized", display them on screen and be able to "swap" between two videos. To make things even more easy of course, I have to do all this in the Flex framework.

       

      So I'm using a ParallelElement, in which I add 2 VideoElement instances

       

      and for the "display" I'm using the MediaPlayerWrapper (that i found in the OSMF source) ,

       

      So to display the first video I just use this simple statement

       

      mediaPlayerWrapper.mediaElement = parallelElement.getChildAt(0);

       

      ... I was thinking that by doing

       

      mediaPlayerWrapper.mediaElement = parallelElement.getChildAt(1);

       

      I'd automatically display the second video, and actually, this works, but the videos "restart" each time I swap between the two video elements,

       

      Any help would be much appreciated

      Thanks!

      J

        • 1. Re: "Swapping" media elements, in a parallel element
          bringrags Level 4

          This is a use case we also ran across fairly recently.  Rather than approach it by trying to switch between elements that are passed to the MediaPlayerWrapper, I'd encourage you to try to model the switching behavior within a single MediaElement (i.e. so that you don't switch elements out of the MediaPlayerWrapper).  Switching elements at the MediaPlayer level is equivalent to saying "the previous video is done, here's the next one" -- that's why they restart upon each switch.


          The MediaElement-based solution can be seen in our ExamplePlayer sample app here (search for "Switching Proxy") and here.  The idea is that you place your two VideoElements behind a single ProxyElement, where the ProxyElement is capable of switching between the two videos.  The ProxyElement models the same API as all other MediaElements, and automatically dispatches the appropriate events when you change what it proxies, so the transitions from one video to the next should be smooth.  The sample version switches back and forth between videos based on a timer, but you could change the switching logic based on your requirements.

          • 2. Re: "Swapping" media elements, in a parallel element
            jcastelain Level 1

            Brian,

             

            Thanks a lot for taking the time to answer to this question, your answer really helped.

             

            Anyway, thanks to your reply, I'm now able to display one of my videos in a Canvas, while the second is displayed in a "customized / resizable" TitleWindow (that's is added to the display list with the PopUpManager class), and I have the ability to toggle / switch the place where videos are displayed

             

            Thanks again,

            I'll probably ask you more questions in the days/weeks to come,

             

            Kudos to the OSMF team  : great great stuff

             

            Julien