MediaPlayer loses orientation on Android 2.3.7

182 Views Asked by At

I've came across a weird phenomena when implementing an Android MediaPlayer with SurfaceView. The bug only happens on a device with Android 2.3.7 (Samsung Galaxy S1).

Activity A is a full screen video activity which supports landscape only. When clicking a link over the video, I pause the video and opens an internal browser, which also supports portrait orientation. After closing the internal browser activity, Activity A is resumed, and should resume the video.

I call MediaPlayer.setDisplay() when getting a surfaceCreated and surfaceChanged callbacks, and call MediaPlayer.setDisplay(null) when getting surfaceDestroyed.

What happens, is that after getting back to the full screen activity, the entire activity is in landscape mode, and only the video is in portrait mode. It remains in portrait mode even if I rotate the device.

2 more things: - It does not happen on 4.0 and above. The video resumes in landscape mode as intended. - It happens only if I click the link button when I hold the device in portrait mode (The activity is still in landscape mode, but the device is held in landscape). If I first rotate the device to landscape and then click the link, when coming back from the internal browser, the video orientation is ok.

So it looks like it has something to do with detaching the surface, and not with the re-attaching.

Any clue?

Thanks

1

There are 1 best solutions below

0
On

Very late to answer this, but setting android:screenOrientation="fullSensor" directly on my video player activity fixed my MediaPlayer orientation issue.