From 3aa2f1b08358bf29b20d108edc61d69943dbfa09 Mon Sep 17 00:00:00 2001 From: eikarna Date: Mon, 14 Oct 2024 15:04:29 +0700 Subject: [PATCH 1/2] Apply keep screen on --- .../java/com/eikarna/smoothvideoapp/FilterWorker.java | 11 ++++++++++- .../java/com/eikarna/smoothvideoapp/MainActivity.java | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/eikarna/smoothvideoapp/FilterWorker.java b/app/src/main/java/com/eikarna/smoothvideoapp/FilterWorker.java index dc2c64b..82fe546 100644 --- a/app/src/main/java/com/eikarna/smoothvideoapp/FilterWorker.java +++ b/app/src/main/java/com/eikarna/smoothvideoapp/FilterWorker.java @@ -17,6 +17,7 @@ public class FilterWorker extends Worker { private static final String TAG = "FilterWorker"; + private FFmpegSession session; public FilterWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { super(context, workerParams); @@ -84,7 +85,7 @@ public Result doWork() { }); // Execute the FFmpeg command - FFmpegSession session = FFmpegKit.execute(ffmpegCommand.toString()); + session = FFmpegKit.execute(ffmpegCommand.toString()); Log.d(TAG, "FFmpeg output: " + session.getOutput()); Log.e(TAG, "FFmpeg error: " + session.getFailStackTrace()); @@ -97,6 +98,14 @@ public Result doWork() { return Result.failure(); } } + + @Override + public void onStopped() { + super.onStopped(); + if (session != null) { + session.cancel(); // Stop FFmpeg session gracefully + } + } // Function to format the log message private String formatLogMessage(String message) { diff --git a/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java b/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java index 50afc5c..42d389c 100644 --- a/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java +++ b/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java @@ -11,6 +11,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; @@ -251,13 +252,22 @@ private void acquireWakeLock() { wakeLock = powerManager.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "SmoothVideoApp::VideoProcessingLock"); +<<<<<<< Updated upstream wakeLock.acquire(60); +======= + wakeLock.acquire(); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); +<<<<<<< Updated upstream +>>>>>>> Stashed changes +======= +>>>>>>> Stashed changes } private void releaseWakeLock() { if (wakeLock != null && wakeLock.isHeld()) { wakeLock.release(); } + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } private void selectVideo() { From 3a28565c545c86ba91eaec2cfecd7b8cc8066f22 Mon Sep 17 00:00:00 2001 From: eikarna Date: Mon, 14 Oct 2024 15:08:48 +0700 Subject: [PATCH 2/2] remove git stash message. --- .../main/java/com/eikarna/smoothvideoapp/MainActivity.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java b/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java index 42d389c..de7af8b 100644 --- a/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java +++ b/app/src/main/java/com/eikarna/smoothvideoapp/MainActivity.java @@ -252,15 +252,8 @@ private void acquireWakeLock() { wakeLock = powerManager.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "SmoothVideoApp::VideoProcessingLock"); -<<<<<<< Updated upstream - wakeLock.acquire(60); -======= wakeLock.acquire(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); -<<<<<<< Updated upstream ->>>>>>> Stashed changes -======= ->>>>>>> Stashed changes } private void releaseWakeLock() {