Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Embedding VideoViews in your UI: Caution!

Using a VideoView to play streaming videos is quite easy on Android, and the class provides handy callbacks to manage your UI too. For example:

    // set the Uri of the video
    // start streaming/playing the video

    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        public void onPrepared(MediaPlayer mp) {
            // about to start playing

    videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        public void onCompletion(MediaPlayer mp) {
            // reached the end of the video

VideoViews can be embedded into your layouts and sized any way that you’d like. However, there is one serious limitation.

According to Romain Guy, SurfaceViews (such as VideoView, etc.) inside ScrollViews (or ListView, etc.) are not supported by Android.

For example, playing a video using a VideoView inside of a row of a ListView seems to work at first, until the user tries to scroll the list. As soon as the list starts to scroll, the video turns black. It keeps playing in the background but you can’t see it anymore because it renders the rest of the video as a black box.

As another example, when the VideoView is scrolled so that it is partially off-screen at the time that the video starts playing, the VideoView does not render the video in the correct location on screen, causing the video to appear mostly black.

So be careful where you decide to put your VideoViews. At first it seems that they can go anywhere, but they cannot.

  1. dzban says:

    So how Vine app is doing it?
    They seem to have list of VideoViews inside ListView.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *