4 Replies Latest reply on Dec 22, 2010 11:31 AM by ptaranto

    pre-buffering main content during ads

    mediabits Level 1

      What is the best way to buffer and play an ad, then buffer and wait to play a video? We'd like to be able to start buffering the main content once the ad has finished loading to give the best user experience.


      (This question comes from a customer.  Reposting here for the OSMF team to respond and for the benefit of the whole group.)


      Sumner Paine
      osmf product manager

        • 1. Re: pre-buffering main content during ads
          ptaranto Level 1

          I know the post is a bit old, but I also want some advice on how is the best way to do it.





          Pedro Taranto

          • 2. Re: pre-buffering main content during ads
            Andrian Cucu Adobe Employee



            There are two possible technical approaches to this:


            1. Create a ProxyElement which would switch from the ad and the main video content and where you can control the pre-buffering behavior. The closest sample for this is OSMF\1.5gm\apps\samples\framework\ExamplePlayer\org\osmf\examples\switchingproxy\Switchin gProxyElement.as.


            You'll need to use the Traits API and If you are working on a plugin, this is the only option you have.


            2. If you are working on custom video player, the following approach might be somewhat simpler.

            2.1 Create a custom MediaPlayer  (MyMediaPlayer extends MediaPlayer)

            2.2 Add a prebuffer method (and implement it ~= mute, play, pause, seek(0), unmute)

            2.3 Use this class for controlling the playback and the prebuffering for both your main video and the ads


            Let us know which approach you choose to implement. I'd really like to get your feedback on this.



            • 3. Re: pre-buffering main content during ads
              ptaranto Level 1

              Hi Andrian,


              Thanks for your reply and suggestions.


              I was creating each element as soon the player need them to be played, but to do a pre-buffer/load I will need to create all the elements at the same time.


              I was trying to discover how I could start to load an element without having to pass it to the mediaPlayer, the SwitchingProxyElement give me the hint on how to do it.


              As my player should be flexible (should be able to have or not a pre-roll and/or post-roll) and I have some custom view for each state (initial thumb, pre-roll, video content, post-roll, related list), I think I'll have to mix a little the 2 approaches you suggested, managing the load of my elements individually in my MainPlayer class but not as a ProxyElement or extending the MediaPlayer.


              As I have some view states, I will need to keep track and control of each element to know how to manage my views and to be able to replay each of them separately after they are all played. So I dont think using a SerialElement or any extension of that will help in an easy way, I would need to pass a lot of references to be able to manage my player in a custom class.


              Neither extending MediaPlayer, I would need to hack it to handle 2 media elements, because when the mediaPlayer.media is changed it automatically unload the current media element, so dont think its not a good idea. As I'm already using composition, I think it will be easier to manage each element by itself and control what and when to pass do mediaPlayer instance. I'll try fist using the LoadTrait, if I dont have success will try using the AudioTrait and PlayTrait as you also suggested.


              Do you have any other suggestion with this scenario?





              Pedro Taranto

              • 4. Re: pre-buffering main content during ads
                ptaranto Level 1

                So I choose the 2nd approach, I know that doing a refactoring it could be done using proxy elements and letting my custom media player to manage them. But its working for now.


                Thanks for the suggestios Andrian.



                Pedro Taranto