From baa3f449314d43e2be1185ea82fc5ed81890c30b Mon Sep 17 00:00:00 2001 From: Xu Xiaowei Date: Tue, 11 Jul 2023 15:02:39 +0800 Subject: [PATCH] fix the width and height not working issue --- .../ed_screen_recorder/EdScreenRecorderPlugin.java | 11 +++++++++-- .../ed_screen_recorder/ed_screen_recorder_plugin.dart | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/ed_screen_recorder/ed_screen_recorder/EdScreenRecorderPlugin.java b/android/src/main/java/com/ed_screen_recorder/ed_screen_recorder/EdScreenRecorderPlugin.java index ad18620..b511386 100644 --- a/android/src/main/java/com/ed_screen_recorder/ed_screen_recorder/EdScreenRecorderPlugin.java +++ b/android/src/main/java/com/ed_screen_recorder/ed_screen_recorder/EdScreenRecorderPlugin.java @@ -66,6 +66,8 @@ public class EdScreenRecorderPlugin implements FlutterPlugin, ActivityAware, Met String videoHash; long startDate; long endDate; + int width; + int height; boolean micPermission = false; boolean mediaPermission = false; @@ -134,7 +136,9 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { fileExtension = call.argument("fileextension"); videoHash = call.argument("videohash"); startDate = call.argument("startdate"); - customSettings(videoFrame, videoBitrate, fileOutputFormat, addTimeCode, fileName); + width = call.argument("width"); + height = call.argument("height"); + customSettings(videoFrame, videoBitrate, fileOutputFormat, addTimeCode, fileName, width, height); if (dirPathToSave != null) { setOutputPath(addTimeCode, fileName, dirPathToSave); } @@ -339,13 +343,16 @@ private Boolean startRecordingScreen() { } private void customSettings(int videoFrame, int videoBitrate, String fileOutputFormat, boolean addTimeCode, - String fileName) { + String fileName, int width, int height) { hbRecorder.isAudioEnabled(isAudioEnabled); hbRecorder.setAudioSource("DEFAULT"); hbRecorder.setVideoEncoder("DEFAULT"); hbRecorder.setVideoFrameRate(videoFrame); hbRecorder.setVideoBitrate(videoBitrate); hbRecorder.setOutputFormat(fileOutputFormat); + if (width != 0 && height != 0) { + hbRecorder.setScreenDimensions(height, width); + } if (dirPathToSave == null) { hbRecorder.setFileName(generateFileName(fileName, addTimeCode)); } diff --git a/lib/src/ed_screen_recorder/ed_screen_recorder_plugin.dart b/lib/src/ed_screen_recorder/ed_screen_recorder_plugin.dart index d9c4aa0..ec7ae9c 100644 --- a/lib/src/ed_screen_recorder/ed_screen_recorder_plugin.dart +++ b/lib/src/ed_screen_recorder/ed_screen_recorder_plugin.dart @@ -39,6 +39,8 @@ class EdScreenRecorder { "fileextension": fileExtension, "videohash": videoHash, "startdate": dateNow, + "width": width ?? 0, + "height": height ?? 0, }); var formatResponse = RecordOutput.fromJson(json.decode(response)); if (kDebugMode) {