Search code examples
androidandroid-mediarecorderscreen-recordingandroid-mediaprojection

Android Screen Recording How-To - Landscape recording, video recorded plays in full-screen vs partial-screen


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!


Solution

  • 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 */);