I've got a simple Activity that plays a video.
uriStr = ("http://pathToVideo.com/video/" + yyyyMdd_Str + "/" + yyyyMdd_Str + ".mp4");
VideoView testVideo1_VV =(VideoView) findViewById(R.id.videoTest7vid_VV);
testMediaCon1_MC = new MediaController(this);
testMediaCon1_MC.setAnchorView(testVideo1_VV);
testVideo1_VV.setMediaController(testMediaCon1_MC);
testVideo1_VV.setKeepScreenOn(true);
testVideo1_VV.setVideoPath(uriStr);
testVideo1_VV.requestFocus();
testVideo1_VV.start();
In the portrait layout, the video is aligned to the top so that it plays in the top third of the screen, and in the landscape layout, the video is full screen by wrapping content on both height and width. In the Manifest I've set android:configChanges="orientation"
so that the Activity doesn't refresh on orientation change. But my problem is that the layout doesn't change with orientation change. How can I keep the video playing when the orientation changes, but also get the correct layout to display on orientation change?
So now I think the solution is to note the video's position on playback and then use savedInstanceState
to retrieve the video state and start the video from that point upon orientation change. Something like this:
@Override
protected void onSaveInstanceState(Bundle out) {
super.onSaveInstanceState(out);
//video state would go here
}
@Override
protected void onRestoreInstanceState(Bundle in) {
super.onRestoreInstanceState(in);
//video state would go here
}
But now I don't know the code to grab the video's state...