Skip to content

Commit

Permalink
Fix #166
Browse files Browse the repository at this point in the history
  • Loading branch information
HBiSoft committed Aug 12, 2024
1 parent ad9d63b commit daad574
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Binary file modified app/release/HBRecorderDemo.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Countdown(long totalTime, long interval, long delay) {

public void start() {
wasStarted = true;
this.scheduleAtFixedRate(task, delay, interval);
this.schedule(task, delay, interval);
}

public void stop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,19 @@ private void setAudioSourceAsInt(String audioSource) {
private void initMediaProjection() {
mMediaProjection = ((MediaProjectionManager) Objects.requireNonNull(getSystemService(Context.MEDIA_PROJECTION_SERVICE))).getMediaProjection(mResultCode, mResultData);
Handler handler = new Handler(Looper.getMainLooper());
mMediaProjection.registerCallback(new MediaProjection.Callback() {
// Nothing
// We don't use it but register it to avoid runtime error from SDK 34+.
}, handler);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
mMediaProjection.registerCallback(new MediaProjection.Callback() {
@Override
public void onStop() {
super.onStop();
}
}, handler);
} else {
mMediaProjection.registerCallback(new MediaProjection.Callback() {
// Nothing
// We don't use it but register it to avoid runtime error from SDK 34+.
}, handler);
}
}

//Return the output file path as string
Expand Down Expand Up @@ -568,6 +577,10 @@ private void initRecorder() throws Exception {

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void initVirtualDisplay() {
if (mMediaProjection == null) {
Log.d(TAG, "initVirtualDisplay: " + " Media projection is not initialized properly.");
return;
}
mVirtualDisplay = mMediaProjection.createVirtualDisplay(TAG, mScreenWidth, mScreenHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mMediaRecorder.getSurface(), null, null);
}

Expand Down

0 comments on commit daad574

Please sign in to comment.