Play video in Android listview - android

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

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.

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

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

Related

Is it possible to add custom view on DefaultTimeBar in ExoPlayer

Need to add custom views on the DefaultTimeBar in Exoplayer at particular timestamps to indicate that there is something which is coming up during the video play similar to what we have in terms of video ads.
Please find the attached image to understand the exact requirement.

VideoView on RecyclerView

I'm developing a social media app which has feed tab based on RecyclerView. On that feed tab I have many types of feedtype like text, photo, photo and text, book, etc... So till now I didn't had any problem about this. On my view holder I've Middle Item Container Panel. I'm putting template which is coming from my feedtypemanager class. So now I need to add videoview for my video feeds. First problem is I'm using rtsp server for streaming. VideoView starting after 15 seconds from seeing that view. Second one is when I scroll down and come up again my VideoView starting from beginnging and I'm waiting 15 seconds again to play that video. So how can I do that view like Instagram fast ? Which protocol I should use and Which VideoPlayer ? Thanks for help.
I've faced the same issues with videoview,
I would recommend to use Exomedia library and make your life easy with that.
For smooth video playback use some caching mechanism.
I would recommend AndroidVideoCache Library.
Use app:useTextureViewBacking="true" for smooth animations and transitions of videoview.

android youtube player get current frame

I'd like to know if there is a way to get current frame as a bitmap from an integrated yoube player from a youtubePlayerFragment.
I didn't find such method, and I already tried to extract a bimap from fragment's view but the bitmap doesn't contains the drawing elements from the video I only have buttons and progress bar. Any one knows how to get it?
Regards,
I took a look at the reference found in Package Summary for Youtube API and it seems this feature is not yet supported.
Also, I found this thread that this kind of action may be violating Youtube's terms.

How to get overlay on Video Player in activity

On Video players such as Youtube, I often see that when the user taps on the video view a sort of overlay shows up where the user can choose actions like: “share”, “add to playlist”, “pause”, etc. Basically it’s whatever the developer wants. The developer seems to be able to choose what the icons are, where they go, etc.
I would like to know how it’s done. For example, are they using a VideoView with an overlay? Are they using a FrameLayout with a VideoView and a RelativeLayout on top of the VideoView? I just need some advice in the right direction as I don’t know where to start. Thanks. For simplicity, I am looking to add a Youtube style video player to my activity. And by Youtube style, I am referring to the aforementioned interactions.
I would like to know how it’s done
I am sure that the implementation varies widely.
For example, are they using a VideoView with an overlay?
AFAIK, few professional-grade apps use VideoView, simply because VideoView offers little in the way of events or control. More likely, they are using something else backed by MediaPlayer or third-party media libraries (e.g., ExoPlayer).
Are they using a FrameLayout with a VideoView and a RelativeLayout on top of the VideoView?
No, because that would be two VideoView widgets. However, whatever their video surface is probably resides in a RelativeLayout or FrameLayout, with the overlay as another child of that same container, though I am sure that there are other approaches.
You are welcome to use uiautomatorviewer to try to learn more about the view hierarchy of particular apps of interest.

How to play an animated gif (or a video) on the background of a layout?

In my spare time I'm learning android. I want to create a layout with a background image which includes an animation.
I know how to use linearLayout.setBackgroundDrawable(R.drawable.BlaBla) but if I place a gif image it becomes a static image but not animated. Also, I'm not sure if I can play a video on it. Can anyone post a simple code or just give the directions about that if possible? Minsdk version will be 8 (2.2).
PS: I know I can use media to play videos using VideoView but it's not a layout, therefore, I can't add some views on it. Please don't suggest that.
I don't think you can just use gif.
Maybe this will help if you want to animate something:
http://developer.android.com/guide/topics/resources/animation-resource.html
With video, I think you should not just put it in background but use media player and then perhaps have some layouts on top if you want to overlay it with some info.
Hope this helped.
Maybe you can try a webView, I've never tested that:
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://img.gif");

Categories

Resources