I\'ve created a layout.xml file with the following XML, but I can\'t get the MediaController to appear at all.
When declaring my MediaController in a layout file, getting a handle on it in code (using the Activity.findViewById(int id) method) and attaching it to my VideoView (using the VideoView.setMediaController(MediaController controller) method), I find it behaves undesirably (force closes the app) at times. Instead, I create it in code, attach it to the VideoView and then specify where it should display in the Activity using the VideoView.setAnchorView(View view) method as follows:
myVideoView.setVideoURI(Uri.parse(myVideoUrl));
myVideoView.setOnPreparedListener(new OnPreparedListener()
{
public void onPrepared(MediaPlayer mp)
{
MediaController mediaController = new MediaController(MyActivity.this);
videoView.setMediaController(mediaController);
// put the MediaController at the bottom of the Activity rather than directly beneath the VideoView
// (note that my Activity's layout file has root node with id 'myactivity_layoutroot')
if (findViewById(R.id.myactivity_layoutroot) != null)
mediaController.setAnchorView(findViewById(R.id.myactivity_layoutroot));
videoView.requestFocus();
}
});
myVideoView.start();