eneim / toro

Video list auto playback made simple, specially built for RecyclerView
Apache License 2.0
1.42k stars 253 forks source link

Black background on Video while scrolling #338

Open brijhub opened 6 years ago

brijhub commented 6 years ago

I have three categories of items (Text/Image/Video) in recyclerview. For text and Image I'm showing Imageview in layout and for Video I'm showing PlayerView.

Now the problem is, While scrolling, It shows blank screen on Playerview and after few seconds It start playing and even sometimes It doesn't play (When scrolling up and down again and again)

Version I'm using implementation "im.ene.toro3:toro:3.4.2" implementation "im.ene.toro3:toro-ext-exoplayer:3.4.2"

This is what I'm using

<com.google.android.exoplayer2.ui.PlayerView
                                    android:id="@+id/video_view"
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    app:surface_type="texture_view"
                                    app:resize_mode="fixed_width"
                                    app:use_controller="false"
                                    android:visibility="visible" />

I tried many things to overcome black screen problem but still problem exists. Looking for your support please have a look into it.

eneim commented 6 years ago

@brijhub You should prepare a thumbnail, and show it in initialize() method, hide it when your Player starts playing. It should hide the black screen.

eneim commented 6 years ago

@brijhub Do you have any further issue on this? Can I close the issue?

foodied commented 6 years ago

@eneim In my case, PlayerView is recycled when it goes out of screen hence playerView.setArtwork(bitmap) doesn't seem to be a seamless experience. What alternatives do I have other than having to keep an ImageView separately?

Also (not relevant to the topic) how can we use DASH configuration with Config class?

eneim commented 6 years ago

@foodied In fact my current 'not worst practice' is to have an ImageView separately. Because PlayerView is a FrameLayout, you can put the ImageView as a child of PlayerView.

Config has a field for MediaSourceBuilder, which will be one to handle DASH media source.

Default one is already built-in: see this line

foodied commented 6 years ago

Yes that's what I did as an alternative to keep as a child of the PlayerView. I was thinking of making two adjacent players ready (like ViewPager) but now it seems like to be a bit heavy. This is a nice solution though.

Thanks for the DASH hint! :)

eneim commented 6 years ago

Yeah the artwork is specified for audio playback though, when you have Video stream it is hidden by default and cannot be shown from out side.

There is “ShutterView” which is expected to be a solid color (or some ColorDrawable background. I’m about to create a PR to ExoPlayer lib to have this view accept an abitrary Drawable as shutter background. This can help to reduce the amount of View we need.

foodied commented 6 years ago

So you're telling that the artwork is not advisable for video playback but then how would one show the player icon (similar to the custom one set to the controller) over the bitmap other than manually drawing it?

ShutterView with drawable is a good idea though. I wish also we could somehow manage the visibility of the background dynamically.

eneim commented 6 years ago

@foodied The player icon would be different. Saying I want it to be a part of Controller, I will make custom ControlView, make it height to match parent and put the icon to the center of it. ExoPlayer and PlayerView allow you to have custom controller view so it is possible.

eneim commented 6 years ago

@foodied FYI this is the line about artwork view: PlayerView.java#L1012

foodied commented 6 years ago

I understand but ControlView is not visible when the player has been recycled/ first time and is just peeking in the screen.

eneim commented 6 years ago

@foodied I know what you mean. So yeah ControlView may not the one you want to use for a custom image when Video is not available. As I said before, keeping an ImageView on top is current way to go ... and If I can make it to have ShutterView to show custom image instead of solid color, also the ability to show/hide it on-demand, we can do much more :D.

foodied commented 6 years ago

Absolutely... best solution!

anubhavmalik commented 4 years ago

It is exo player's issue, I fixed it by using an image on top of player view but still there was a moment in between when black screen was visible. Check my answer here

Do upvote if you find it useful :)