Mehul Joisar
Mehul Joisar

Reputation: 15358

Force to capture video in Landscape

I am trying to insist user to use Landscape mode while capturing video.

Question 1: Can I force user to use landscape mode while video capturing?
Question 2: Can I show some overlay image or alert to suggest the user for landscape mode when user holds device in portrait mode?

I tried to achieve it by using default Camera App with following piece of code,

Intent mOptionIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
mOptionIntent.putExtra("return-data", true);
startActivityForResult(mOptionIntent, REQUEST_CAPTURE_VIDEO);

I found that we can request for orientation of output data by specifying EXTRA_SCREEN_ORIENTATION as shown below.It can work on some devices only if OEMs have not modified, And even if it happens, the Camera might be open in Portrait and save data with Landscape orientation, so there is no way to set Landscape camera:

mOptionIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

So my concern is about orientation while Video capturing, I want to insist user or lock the screen in Landscape mode.

Upvotes: 4

Views: 2266

Answers (1)

Jeroen Mols
Jeroen Mols

Reputation: 3464

I've created a library called LandscapeVideoCapture which does exactly that.

In portrait you will get an image indicating that the user should rotate his device and only when the device is in landscape, the user can actually start capturing a video.

Check it out here: https://github.com/jmolsmobile/LandscapeVideoCapture

Further this library has many other features such setting resolution, framerate, capture quality,...

Upvotes: 5

Related Questions