Skip to content

Commit

Permalink
fix(YouTube/Overlay buttons): Always repeat button doesn't work whe…
Browse files Browse the repository at this point in the history
…n the video is minimized inotia00/ReVanced_Extended#2293
  • Loading branch information
inotia00 committed Aug 7, 2024
1 parent 12da0eb commit 0f0a6c9
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package app.revanced.integrations.youtube.patches.utils;

import android.util.Log;
import android.content.Context;
import android.media.AudioManager;

import app.revanced.integrations.shared.utils.Utils;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.shared.VideoInformation;

@SuppressWarnings("unused")
public class AlwaysRepeatPatch {
public class AlwaysRepeatPatch extends Utils {

/**
* Injection point.
Expand All @@ -21,17 +23,17 @@ public static boolean alwaysRepeatEnabled() {
final boolean alwaysRepeat = Settings.ALWAYS_REPEAT.get();
final boolean alwaysRepeatPause = Settings.ALWAYS_REPEAT_PAUSE.get();

if (alwaysRepeat && alwaysRepeatPause) pauseVideo();
if (alwaysRepeat && alwaysRepeatPause) pauseMedia();
return alwaysRepeat;
}

/**
* Pause the current video.
* Rest of the implementation added by patch.
* Pause the media by changing audio focus.
*/
private static void pauseVideo() {
// These instructions are ignored by patch.
Log.d("Extended: AlwaysRepeatPatch", "AlwaysRepeatAndPauseState: " + Settings.ALWAYS_REPEAT_PAUSE.get());
private static void pauseMedia() {
if (context != null && context.getApplicationContext().getSystemService(Context.AUDIO_SERVICE) instanceof AudioManager audioManager) {
audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
}
}

}

0 comments on commit 0f0a6c9

Please sign in to comment.