Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

增加RecycleView 滑动监听,实现自动播放可见区域内的第一个视频Item #1671

Closed
wants to merge 7 commits into from

Conversation

SiXuManYan
Copy link

增加RecycleView 滑动监听,实现自动播放可见区域内的第一个视频Item

备注:
但是刚进来时需要划一下才能自动播放


@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
Copy link
Author

@SiXuManYan SiXuManYan Mar 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

根据自己需要来决定是否调用
super.onScrollStateChanged(recyclerView, newState);
以及
super.onScrolled(recyclerView, dx, dy);

@lipangit
Copy link
Owner

lipangit commented Mar 8, 2018

列表正在滑动的时候会暂停视频的播放,这个不需要吧

@lipangit
Copy link
Owner

lipangit commented Mar 8, 2018

兄弟有微博吧,微博就是这个功能的,咱们这个分支就把微博的列表滑动自动播放的功能copy出来,就这个目标

@SiXuManYan
Copy link
Author

我想的是:

在滑动状态下(SCROLL_STATE_DRAGGING 或者 SCROLL_STATE_SETTLING)暂停播放来减少可能引起的列表卡顿,
停止滑动后(SCROLL_STATE_IDLE),再次for循环检测出完整显示出来的播放器控件,进行播放

好的,我再参照下微博效果,改一下~

当停止滑动时,遍历找出可见区域内的第一个播放器控件,进行视频播放,类似微博效果。

(播放器控件被屏幕顶部或者底部遮罩时,才停止播放视频,--> 框架本身就支持这个)
@lipangit
Copy link
Owner

lipangit commented Mar 9, 2018

干巴得

JZVideoPlayerManager.getCurrentJzvd().currentScreen --> NullPointerException
详细描述请参阅 #1681
@SiXuManYan SiXuManYan closed this Mar 14, 2018
@SiXuManYan
Copy link
Author

已经在新的PR上更正了代码

@getglory
Copy link

autoPlay方法里的for (int i = 0; i < visibleCount; i++),应该改成i <= visibleCount吧? 其实用firstVisibleItemPosition 和 lastVisibleItemPosition计算可见的item数,应该+1

@lipangit
Copy link
Owner

@getglory 测试过吗

@bard0x
Copy link

bard0x commented Apr 13, 2018

If I want to play the video not only if the videoplayer is centered on my recyclerview but also if it is visible at half for example? It's possibile with a specific condition in this if statement?

                    Rect rect = new Rect();
                    homeGSYVideoPlayer.getLocalVisibleRect(rect);
                    int videoheight = homeGSYVideoPlayer.getHeight();
                    if (rect.top == 0 && rect.bottom == videoheight) {
                        handleVideo(handleVideoTag, homeGSYVideoPlayer);
                        // 跳出循环,只处理可见区域内的第一个播放器
                        break;
                    }

@bard0x
Copy link

bard0x commented Apr 13, 2018

@getglory @lipangit
Yes. With the <= condition it works perfectly.

@getglory
Copy link

@lipangit 我这边试了没什么问题

@lipangit
Copy link
Owner

你好,咱们项目推出数字通证饺子token,https://github.com/lipangit/JZT, 给所有提交过pr的朋友30000个JZT,表示对你过去对项目支持的感谢。
请下载币威钱包https://www.bitcv.app/,把里面的以太坊地址给我,币威的地址站内转账不需要手续费。这东西值不值钱不重要,玩的是信仰。
Hello, let's launch the JiaoZiToken, https://github.com/lipangit/JZT, and give all the friends who submitted pr 30,000 JZT, thank you for your support of the project.
Please download the coin wallet https://www.bitcv.app/?from=bitcvCom and give me the address of the Ethereum. There is no charge for transferring money at the address station. It is not important that the value of this thing is worthless. It is faith.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants