I have an Activity that uses a VideoView to play a video file. The onCreate method sets the orientation to Landscape, and then loads the video and plays it.
This video activity is called from my main activity. The main activity is set to portrait orientation in the manifest.
This all works great when the phone is held vertically. - Main Activity starts in portrait - Click button to launch video activity - Video activity launches in landscape - Video plays
However, if the phone is help horizontally, the video does not start playing: - Main Activity starts in portrait - Click button to launch video activity - Video activity launches in landscape - Video is loaded but is paused - have to manually start.
Any ideas on why this might be happening?
Video Activity Code:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.video_view);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
mVideoView = (VideoView)this.findViewById(R.id.VideoView);
String videoUrl = "/mnt/sdcard-ext" + "/Videos/Wildlife.wmv";
playVideo(videoUrl);
// video finish listener
mVideoView.setOnCompletionListener(new MyOnCompletionListener());
}
public void playVideo(String videoUrl)
{
MediaController mc = new MediaController(this);
mc.setAnchorView(mVideoView);
mVideoView.setMediaController(mc);
mVideoView.setVideoURI(Uri.parse(videoUrl));
mVideoView.requestFocus();
mVideoView.start();
}