Play video in Android listview

2019-05-11 22:23发布

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条回答
看我几分像从前
2楼-- · 2019-05-11 22:46

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

查看更多
趁早两清
3楼-- · 2019-05-11 23:03

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).

查看更多
我想做一个坏孩纸
4楼-- · 2019-05-11 23:04

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.

查看更多
登录 后发表回答