Skip to content

Commit

Permalink
Add pause/resume requested in #5
Browse files Browse the repository at this point in the history
  • Loading branch information
HBiSoft committed Sep 2, 2020
1 parent dc0f200 commit 4cd0660
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 156 deletions.
29 changes: 28 additions & 1 deletion hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class HBRecorder implements MyListener {
private String outputFormat = "DEFAULT";
private int orientation;
boolean wasOnErrorCalled = false;
Intent service;
boolean isPaused = false;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public HBRecorder(Context context, HBRecorderListener listener) {
Expand Down Expand Up @@ -184,6 +186,31 @@ public void stopScreenRecording() {
context.stopService(service);
}

/*Pause screen recording*/
@RequiresApi(api = Build.VERSION_CODES.N)
public void pauseScreenRecording(){
if (service != null){
isPaused = true;
service.setAction("pause");
context.startService(service);
}
}

/*Pause screen recording*/
@RequiresApi(api = Build.VERSION_CODES.N)
public void resumeScreenRecording(){
if (service != null){
isPaused = false;
service.setAction("resume");
context.startService(service);
}
}

/*Check if video is paused*/
public boolean isRecordingPaused(){
return isPaused;
}

/*Check if recording is in progress*/
public boolean isBusyRecording() {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
Expand Down Expand Up @@ -238,7 +265,7 @@ private void startService(Intent data) {
observer.startWatching();
}

Intent service = new Intent(context, ScreenRecordService.class);
service = new Intent(context, ScreenRecordService.class);
if (mWasUriSet) {
service.putExtra("mUri", mUri.toString());
}
Expand Down
Loading

0 comments on commit 4cd0660

Please sign in to comment.