I have a list of cards using Recycler View of android. I am showing some text and below it video view.
The list was scrolling well with playing video smoothly until I enabled controls using setMediaControll().
After enabling this video media controls when I scroll the list up/down the control stays in the same position even when the video view moves freely along with list view scroll movement.
These control should move along with list view they stay stationary. What may have caused this? Is this expected platform behaviour?
Update code :
Layout :
<FrameLayout
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:id="@+id/frame_layout_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<VideoView
android:id="@+id/video_view"
android:layout_width="360sp"
android:layout_height="225sp"
android:layout_gravity="center" />
<ImageView
android:id="@+id/image_button_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:contentDescription="play_pause_button"
app:srcCompat="@drawable/ic_play_circle_filled_white_24px" />
<ProgressBar
android:id="@+id/progressbar_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:visibility="gone" />
</FrameLayout>
In view holder :
MyViewHolder(View itemLayoutView) {
super(itemLayoutView);
..........
myVideoView = itemLayoutView.findViewById(R.id.video_view);
..........
}
Code to start video playing :
..........
Uri uri = Uri.parse(url);
holder.myVideoView.setVideoURI(uri);
MediaController fsm = new MediaController(mContext,finalistFragment , url, holder.myVideoView);
fsm.setAnchorView(holder.myVideoView);
holder.myVideoView.setMediaController(fsm);
..........
For the list, I am using RecyclerView
.