Home » Android » android – How Do I Play Video in ListView like Instagram and Vine?

android – How Do I Play Video in ListView like Instagram and Vine?

Posted by: admin May 14, 2020 Leave a comment


I’m new to android development and I am trying to play multiple videos in a listview. Currently, each listview row item is a VideoView. This approach has not worked as the VideoViews act abnormally when I begin to scroll. I’ve researched here, here, here and discovered that VideoViews and TextureViews don’t work well within ListViews and ScrollViews. How are apps like vine and instagram able to play videos in listviews? Any help is greatly appreciated?

How to&Answers:

Although the answer is late but i think it might help someone searching for the same. There is a sample app from the github that has implementation for this requirement.:-


For understanding of code refer to the following link it is really helpful for you:-


The problem is that there are some limitations in VideoView in listview
and handling playbacks so this library implement is the VideoView based on the TextureView. Here is it how it looks likeenter image description here


For playing videos in Listview, you need to open Video on Item Click of ListView then you can retrieve your video url in String like:

String  myUrl = urHashMaparraylist.get(position).get("videolocation");

Now pass this myUrl to next Activity and just set this String as a

 Uri video = Uri.parse(myUrl);

listView.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
        String  myUrl = urHashMaparraylist.get(position).get("videolocation");
        Intent n = new Intent(YourActivityName.this , NewActivityName.class);


Now in your next Activity retrieve it as a

Uri video = Uri.parse(url);

In some case,
for setting VideoView,you can use:


as from Android Scrollview having videoview is giving problem

Instead of VideoView you can also try using TextureView for reference you can see number 2 reference:

For more reference for video streaming … you can check the following url: