eneim / toro

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

Play Video at the very bottom of the Recycler View #145

Open tlind15 opened 7 years ago

tlind15 commented 7 years ago

My recycler view contains only videos and the built in MOST_VISIBLE_TOP_DOWN strategy works for all of them except the very last video in the recycler view. Is there a way to simply extend the MOST_VISIBLE_TOP_DOWN strategy so that when the recycler view is at the very bottom the last video plays instead?

eneim commented 7 years ago

@tlind15 This case has been in my backlog for a while. To provide a good UX, it requires some tricks I think. Let me think a bit more about this case.

tlind15 commented 7 years ago

@eneim Thanks!!

sterien7 commented 7 years ago

@eneim I noticed that when I fling to the top or the bottom of the recycler the video that is visible prepares but doesn't start playback. Is there any fix

eneim commented 7 years ago

Please create a separated issue for your question with more info

aldocano commented 6 years ago

Any idea on a workaround for this issue?

eneim commented 6 years ago

@aldocano sadly not yet. I spent a few hours looking around Overscroll API and it doesn't help. I will get back to this later when I could find a better way.

aldocano commented 6 years ago

@eneim what do you suggest for a quick fix than, some view tweaks? Also how to not show black screen before playing videos?

aldocano commented 6 years ago

fixed it with

    @Override public boolean wantsToPlay() {
        return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= 1;
    }
eneim commented 6 years ago

Your solutions doesn’t look elegant to me enough, but it gives me a hint. Let me take a look.

aldocano commented 6 years ago

I didnt find any other idea on how to solve it, what do you suggest?

eneim commented 6 years ago

My previous attempt is to ask Container if it reaches the bottom, the trigger the “reverse PlayerSelector” (that’s why there is that method). But it doesn’t work well.

What I’m thinking now is a dynamic way: pass a callback down to ViewHolder, the callback has the responsibility to tell the ViewHolder if it is the one on the bottom (so ViewHolder must be blind about it situation). The callback is triggered from the “wantsToPlay” and if you have reaches the bottom, all ViewHolder other than the bottom one must return false and the one on the bottom return true. Of course only when it is visible enough.

eneim commented 6 years ago

The callback is just an interface implemented by another class. I’m thinking about the Adapter or the host Activity.

eneim commented 6 years ago

A P/S: your code will not work if there are 2 or more ViewHolder those are fully visible. Also, if the list is infinited, I need a mechanism to handle the event your list is extended (data change callbacks). Will update here later what i can do.

aldocano commented 6 years ago

I the moment of speaking i have 3 recyclerview items, it works. I dont know if some problems might occur if the list is longer. Maybe i might lower the visibleAreaOffset.

Can also help out on the black screen before playing video, is it exoplayer issue or toro's?