2 Replies Latest reply on Feb 11, 2010 2:18 PM by david.t.lanton

    OSMF in Flex: (autoPlay=false) Doesn't Show 1st Frame

    david.t.lanton

      I'm creating a mediaElement, mediaPlayer, and mediaContainer exactly as in the documentation osmf_dev_guide.pdf. The only difference is that I addChild to a UIComponent since I'm in Flex.

       

                  mediaFactory = new DefaultMediaFactory();
                  mediaElement = mediaFactory.createMediaElement(new URLResource(VIDEO_URL));


                 mediaPlayer = new MediaPlayer();
                  mediaPlayer.autoPlay = false;
                  mediaPlayer.media = mediaElement;

       

                  mediaContainer = new MediaContainer();
                  mediaContainer.addMediaElement(mediaElement);

       

                  myMxUiComp.addChild(mediaContainer);

       

      The problem is with the mediaPlayer block in bold. What I'm expecting is a paused mediaPlayer with the first frame showing. What I get is a paused videoPlayer with a blank/white frame (as if the mediaElement has not loaded in the mediaPlayer yet).

       

      If I move the autoPlay line to the bottom to maybe ensure that the mediaElement has loaded into the player, like so, it gets dropped and the video just loads and autoplays as if autoPlay = false is not there.

           mediaPlayer = new MediaPlayer();
            mediaPlayer.media = mediaElement;

           mediaPlayer.autoPlay = false;

       

      same as if we did this:

           mediaPlayer = new MediaPlayer(mediaElement);

           mediaPlayer.autoPlay = false;

       

      I think sandwitching the autoPlay=false in the middle, like the documentation says, is the way to go, because I would think it ensures that the player is paused before any media is inserted (before the mediaElement is assigned). But it'd still want to get the first frame of the video showing, otherwise it looks confusing to the user.

       

      Thanks,

      David

        • 1. Re: OSMF in Flex: (autoPlay=false) Doesn't Show 1st Frame
          bringrags Level 4

          The autoPlay property isn't retroactive, so if you set autoPlay to false after setting the MediaElement on the MediaPlayer then it won't have an effect.

           

          The reason you don't get the first frame when loading the video with autoPlay false is that OSMF takes a conservative approach to loading media.  If we were to show the first frame by default, then we'd trigger the download (for progressive video) or connect to the stream (for streaming).  In both cases, those actions might trigger "false views" on the server side, which we've heard from many customers is a problem to avoid.

           

          Also, in many cases the first frame of a video is uninteresting (e.g. no image, black background), so it makes more sense to display a canned poster frame.  We've experimented with some techniques for doing this in our Example Player sample app (see the "Poster Frame" and "RTMP Poster Frame" examples).  Demo is here, source is here.

           

          Last, I'll add that the behavior you're looking for was considered sufficiently desirable for the Flex video component (which is based on OSMF) that they added native support.  So you might also consider looking at their (Flex 4) component for video.

          • 2. Re: OSMF in Flex: (autoPlay=false) Doesn't Show 1st Frame
            david.t.lanton Level 1

            Thanks for the reply Brian. You're right about the Flex VideoPlayer having the first frame by default, but I already came from it and want to stay with the osmf, because I like what you guys are up to I'll find some workaround for now.

             

            Thanks,

            David