Search code examples
androidandroid-mediaplayerandroid-videoview

How to start playing a video in MediaPlayer before actually completely loading a video


I have wrote a VideoViewActivity with VideoView and MediaPlayer. Now it is taking around 10-15 seconds to start playing a video of around 11MB, 4sec stored in local storage. I heard MediaPlayer was a better option over ExoPlayer for local storage videos. How can I start playing the video as soon as first bits are loaded so that delay between pressing play and actually start playing is reduced. Btw, for comparison, whatsapp loads and plays videos of size even 30MB instantaneously as soon as I click on it!!!


Solution

  • The MediaPlayer decodes and plays the media at the earliest possible. MediaPlayer is better used when we have to use streaming of media from local sources. ExoPlayer on the other hand can be implmented for the streaming sources, say from a website or storage bucket.

    In both the cases the respective players need a chuck of decoded frame data that has to be played. If the format which you are using is complex, there might be long time in decoding it.

    As far as the whatsapp is concerned, it takes the orignal file and compresses it specifically to be used in its media manager.

    I would recommend using exoplayer as it has much more easier handling and lower prepaaration time. Also the streaming is supported.