Play video in Android listview

霸气de小男生 提交于 2019-12-07 12:18:20

问题


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!!!)??


回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/26901693/play-video-in-android-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!