Github address (click to view source code, Demo)
Recently developed a short video project, there are two main ways to achieve online, one is ViewPager, the other is RecyclerView. At that time, I chose RecyclerView without hesitation. In the process of doing it, I found that there were many Demo pits on the Internet, but finally I eliminated the problem and went online smoothly.
To the needs of each package a dependent library, I hope you less detour, use is very simple, on two steps, source code has been uploaded to Github, for you to help welcome star oh, there are issues I, or leave a comment.
Usage:
implementation 'com. Lmxjw3. Media: videoplay: 1.0.0'
Copy the code
1. Reference VideoPlayRecyclerView in XML.
<com.lmx.library.media.VideoPlayRecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" />
Copy the code
2. Use VideoPlayRecyclerView as ordinary RecyclerView, and set Adapter inherit VideoPlayAdapter.
public class MyVideoAdapter extends VideoPlayAdapter {
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return0; } @override public void onPageSelected(int itemPosition, View itemView) {Override public void onPageSelected(int itemPosition, View itemView) {Copy the code