Display A Video In A Videoview From Firebase Url In Android
Solution 1:
The culprit here is android.widget.VideoView
which extends SurfaceView
.
This blog says:
Playing a video using a
VideoView
inside of a row of aListView
seems to work at first, until the user tries to scroll the list. As soon as the list starts to scroll, the video turns black (sometimes displays white). It keeps playing in the background but you can’t see it anymore because it renders the rest of the video as a black box.
I wrote my own VideoView
class which extends TextureView
with the help of this github repository. Though It has some issues as it was written 3 years ago I managed to fix them on my own. Very soon I'll update this answer with my custom Optimized VideoView github repository (just with few modifications). Until then, the link which I've provided would help you.
With the custom Optimized VideoView, the videos will play on scroll in the ListView
just like our Instagram, Facebook, Twitter. We can make the videos play/pause by setting setOnTouchListener()
on VideoView
in our activity and can customize it in our own way.
Now, our VideoView
in the Layouts would be:
<your.packagename.VideoView
android:id="@+id/admin_video_view"
android:layout_width="300dp"
android:layout_height="300dp" />
Post a Comment for "Display A Video In A Videoview From Firebase Url In Android"