Skip to content

Commit

Permalink
Added setOrientationHint
Browse files Browse the repository at this point in the history
  • Loading branch information
HBiSoft committed Jun 16, 2020
1 parent e6fcc1c commit f8f3802
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class HBRecorder implements MyListener {
private int videoFrameRate = 30;
private int videoBitrate = 40000000;
private String outputFormat = "DEFAULT";
private int orientation;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public HBRecorder(Context context, HBRecorderListener listener) {
Expand All @@ -61,6 +62,10 @@ public HBRecorder(Context context, HBRecorderListener listener) {
setScreenDensity();
}

public void setOrientationHint(int orientationInDegrees){
orientation = orientationInDegrees;
}

/*Set output path*/
public void setOutputPath(String path) {
outputPath = path;
Expand Down Expand Up @@ -220,6 +225,7 @@ private void startService(Intent data) {
service.putExtra("quality", isVideoHDEnabled);
service.putExtra("path", outputPath);
service.putExtra("fileName", fileName);
service.putExtra("orientation", orientation);
service.putExtra("audioBitrate", audioBitrate);
service.putExtra("audioSamplingRate", audioSamplingRate);
service.putExtra("notificationSmallBitmap", byteArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class ScreenRecordService extends Service {
private int videoFrameRate;
private int videoBitrate;
private int outputFormatAsInt;
private int orientationHint;

public final static String BUNDLED_LISTENER = "listener";

Expand All @@ -75,6 +76,7 @@ public int onStartCommand(final Intent intent, int flags, int startId) {
String notificationTitle = intent.getStringExtra("notificationTitle");
String notificationDescription = intent.getStringExtra("notificationDescription");
String notificationButtonText = intent.getStringExtra("notificationButtonText");
orientationHint = intent.getIntExtra("orientation", 400);
mResultCode = intent.getIntExtra("code", -1);
mResultData = intent.getParcelableExtra("data");
mScreenWidth = intent.getIntExtra("width", 0);
Expand Down Expand Up @@ -383,6 +385,11 @@ private void initRecorder() throws Exception {
}
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(outputFormatAsInt);

if (orientationHint != 400){
mMediaRecorder.setOrientationHint(orientationHint);
}

if (isAudioEnabled) {
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mMediaRecorder.setAudioEncodingBitRate(audioBitrate);
Expand Down

0 comments on commit f8f3802

Please sign in to comment.