4

I am currently using Media Projection + Media Recorder to do screen recording. The problem I am facing is, when my phone is in Landscape mode during recording, the video recorded will only be shown in the center/middle of the screen with black on top and below it during playback (what it is now, what I would like instead).

I do see apps out there (such as AirShou) that can record in Landscape and the videos they record are full-screen during playback. What do I need to do for that to happen?

Thanks so much!

2 Answers2

3

In your question, you didn't add any problem image. I tried to understand your problem on my way. As i don't have permission to comment yet so just trying to describe the solution with guessing your video is recorded and played fine: 1. During Landscape mode your display width and height changes see this Does the Width and Height change with orientation?

You can re-code by resetting the value of recording screen during screen orientation to Landscape mode. And add a new different layout for orientation to Landscape mood. you can see this

            DisplayMetrics metrics = getResources().getDisplayMetrics();
        int screenWidth = metrics.widthPixels;
        int screenHeight = metrics.heightPixels;
        int screenDensity = metrics.densityDpi;

        // Start the video input.
        mVirtualDisplay = mMediaProjection.createVirtualDisplay("Recording Display", screenWidth,
                screenHeight, screenDensity, 0 /* flags */, mInputSurface,
                null /* callback */, null /* handler */);
Community
  • 1
  • 1
Md. Sulayman
  • 781
  • 8
  • 30
  • Thank you so much for your help! Adjusting/Swapping the width and height helps me achieve what I need to achieve. – Cookies 'n Creme Mar 01 '17 at 02:43
  • So many thanks, This is what @Cookies 'n Creme want to ask in the question. Your answer's 100% working. – User Sep 12 '17 at 05:36
1

If any one is still looking for answer - in addition to what @md-sulayman suggested, make sure you also swap the width height in

mediaRecorder.setVideoSize

like this -

mMediaRecorder.setVideoSize(WIDTH, HEIGHT); // for portrait

and

mMediaRecorder.setVideoSize(HEIGHT,WIDTH); // for landscape
spiraldev
  • 171
  • 1
  • 3
  • we can't change the video size during recording since the documentation states:- "throws IllegalStateException if it is called after prepare() or before setOutputFormat()" – syed_noorullah Feb 14 '21 at 04:51