I'm using a ViewPager
to show several Fragments provided by a FragmentPagerAdapter
. One of these Fragments
shows a VideoView
and an according MediaController
.
The issue I'm facing is, that the MediaController
is not swiping to the left/right as it's supposed to together with the rest of the Fragment
. (Hopefully you can follow me ^^)
I've looked through a lot of similar discussions on StackOverflow, but unfortunatly none of them fixes my issue.
This is my xml for the Fragment
that is instanciated by the adapter:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<VideoView
android:id="@+id/vv_project_details"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
This is code belongs to onCreateView
of the Fragment
:
final VideoView vv = (VideoView) rootView
.findViewById(R.id.vv_project_details);
vv.setVideoURI(Uri uri = new Uri("some-uri"));
mMediaController = new MediaController(getActivity(), false); // should I use rootView.getContext() instead of getActivity()?
vv.setMediaController(mMediaController);
vv.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mMediaController.setAnchorView(vv);
mMediaController.show(0);
}
});
Everything is working fine, except for swiping through my Fragments
, as the MediaController
appears fixed... :-/
Edit: this is a screenshot made while swiping between 2 Fragments
. As you can see, the MediaController
remains at its initial position...