Skip to content

Commit

Permalink
Add skip audio silence option
Browse files Browse the repository at this point in the history
  • Loading branch information
moneytoo committed Sep 11, 2021
1 parent e4eace4 commit 2879d45
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/brouken/player/PlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,12 @@ public void initializePlayer() {
.build();
player.setAudioAttributes(audioAttributes, true);

if (mPrefs.skipSilence) {
if (player.getAudioComponent() != null) {
player.getAudioComponent().setSkipSilenceEnabled(true);
}
}

final YouTubeOverlay youTubeOverlay = findViewById(R.id.youtube_overlay);

youTubeOverlay.performListener(new YouTubeOverlay.PerformListener() {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/brouken/player/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Prefs {
private static final String PREF_KEY_ASK_SCOPE = "askScope";
private static final String PREF_KEY_AUTO_PIP = "autoPiP";
private static final String PREF_KEY_TUNNELING = "tunneling";
private static final String PREF_KEY_SKIP_SILENCE = "skipSilence";

final Context mContext;
final SharedPreferences mSharedPreferences;
Expand All @@ -54,6 +55,7 @@ class Prefs {
public boolean autoPiP = false;

public boolean tunneling = false;
public boolean skipSilence = false;

private LinkedHashMap positions;

Expand Down Expand Up @@ -95,6 +97,7 @@ private void loadSavedPreferences() {

public void loadUserPreferences() {
tunneling = mSharedPreferences.getBoolean(PREF_KEY_TUNNELING, tunneling);
skipSilence = mSharedPreferences.getBoolean(PREF_KEY_SKIP_SILENCE, skipSilence);
}

public void updateMedia(final Context context, final Uri uri, final String type) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
<string name="pref_title">Settings</string>
<string name="pref_general_header">General</string>
<string name="pref_tunneling">Tunneled playback</string>
<string name="pref_skip_silence">Skip silence</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
app:defaultValue="false"
app:title="@string/pref_tunneling" />

<SwitchPreferenceCompat
app:key="skipSilence"
app:defaultValue="false"
app:title="@string/pref_skip_silence" />

</PreferenceCategory>

</PreferenceScreen>

0 comments on commit 2879d45

Please sign in to comment.