Play video in Android listview

3.5k views Asked by At

I am trying to play videos in my listview just like Vine or Instgram. I have been trying to use TextureView with a media player except that when attaching TextureView to the media player I experience issues where the textureview is not being reused properly by the GetView method. The textureview renders some old incorrect videos when scrolling down in my list.

Does anyone know how to play videos in ListViews (Not using VideoView!!!)??

3

There are 3 answers

0
kiki_ygn On

Just wanna give you advice.

You can use WebView inside listview item and using javascript to play the video. you can find the javascript play on html

http://www.w3schools.com/tags/av_prop_autoplay.asp

I hope my advice may help you something out.

1
MoMo On

Found the solution to this problem. I need to use TexutreView with MediaPlayer, and I need to dynamically add the TextureView to each item in the list. I also need to make sure that I remove any previous TexutreViews that was previously attached to the item in the list before adding a new one dynamically. Also, I need to make sure that I only play one MediaPlayer at a time in the listview to avoid causing any strange behaviors (i.e. videos can play in the wrong position).

1
Danylo Volokh On

You really need to use TextureView. There is actually few problems you need to solve.

Please find expanded answer here:

Run media file in CardView layout