I am trying to create a VideoViewer fragment. Below are the 2 cases I
have tried and the observations. For both the cases the fragment's
view is inflated from the following layout:


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

<VideoView android:id="@+id/fragment_video_viewer_video"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center" />
</RelativeLayout>

Case 1: VideoView without media controller - works fine. Below is the
code for the onActivityCreated method

/* Initialize the variables here, retrieve views and  */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Assignment for the local variables
    mVideoView = (VideoView)
getView().findViewById(R.id.fragment_video_viewer_video);
    mVideoView.setVideoPath("/sdcard/family_guy_test.3gp");//
(videoUri);
    mVideoView.requestFocus();
    mVideoView.start();
}

Case 2: VideoView with media controller - App Crashes when I touch on
the VideoView. Below is the code for the onActivityCreated method

/* Initialize the variables here, retrieve views and  */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Assignment for the local variables
    mVideoView = (VideoView)
getView().findViewById(R.id.fragment_video_viewer_video);
    mVideoView.setVideoPath("/sdcard/family_guy_test.3gp");//
(videoUri);
    MediaController mediaController = new
MediaController(getActivity().getApplicationContext());
    mediaController.setAnchorView(mVideoView);
    mVideoView.setMediaController(mediaController);
    mVideoView.requestFocus();
}

Can anyone help me in figuring out what exactly the problem is in case
2? This is the code that is taken from the API demos in the android
sdk. Instead of activity I am trying to have it as a fragment. If
anyone needs the logcat output. I can send it. Its huge.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to