3

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

MoMo
  • 186
  • 1
  • 3
  • 15
  • Please post your code – Blaze Tama Nov 13 '14 at 05:05
  • Are you sure it's not gif images? – StoneBird Nov 13 '14 at 05:11
  • Are these "old incorrect" videos still playing, or is it just the last frame? What makes them incorrect -- should a different video be playing? If so, is that new video playing somewhere else, or not at all? – fadden Nov 13 '14 at 15:36
  • The "old incorrect" videos are mainly videos that were playing in previous/top rows after scrolling down. This was happening because I was reusing the texture view and the media player in my adapter to avoid inflating a new texture view for every list item. However, it seems that reusing texture views and media players is not a good solution and I might have to inflate a new texture view and associate a new Media Player with it for every video. I think the is the way to go but does anyone think there is a way to reuse Media players and texture views in list views..? – MoMo Nov 14 '14 at 06:09

3 Answers3

3

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.

kiki_ygn
  • 85
  • 3
1

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

MoMo
  • 186
  • 1
  • 3
  • 15
1

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

Community
  • 1
  • 1
Danylo Volokh
  • 4,149
  • 2
  • 33
  • 40
  • 1
    Please check out [Take a tour](http://stackoverflow.com/tour) and [Your answer is in another castle: When is an answer not an answer](http://meta.stackexchange.com/questions/225370) – Drew Jan 28 '16 at 16:08