mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-23 23:46:57 +00:00
Added option to resume on audio focus regain. (#624)
This commit is contained in:
parent
10c4f7b465
commit
becc90409f
@ -47,6 +47,8 @@ import com.google.android.exoplayer2.util.Util;
|
|||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.R;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
@ -321,10 +323,21 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isResumeAfterAudioFocusGain() {
|
||||||
|
if (this.sharedPreferences == null || this.context == null) return false;
|
||||||
|
|
||||||
|
return this.sharedPreferences.getBoolean(
|
||||||
|
this.context.getString(R.string.resume_on_audio_focus_gain_key),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected void onAudioFocusGain() {
|
protected void onAudioFocusGain() {
|
||||||
if (DEBUG) Log.d(TAG, "onAudioFocusGain() called");
|
if (DEBUG) Log.d(TAG, "onAudioFocusGain() called");
|
||||||
if (simpleExoPlayer != null) simpleExoPlayer.setVolume(DUCK_AUDIO_TO);
|
if (simpleExoPlayer != null) simpleExoPlayer.setVolume(DUCK_AUDIO_TO);
|
||||||
animateAudio(DUCK_AUDIO_TO, 1f, DUCK_DURATION);
|
animateAudio(DUCK_AUDIO_TO, 1f, DUCK_DURATION);
|
||||||
|
|
||||||
|
if (isResumeAfterAudioFocusGain()) simpleExoPlayer.setPlayWhenReady(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onAudioFocusLoss() {
|
protected void onAudioFocusLoss() {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<string name="autoplay_through_intent_key" translatable="false">autoplay_through_intent</string>
|
<string name="autoplay_through_intent_key" translatable="false">autoplay_through_intent</string>
|
||||||
<string name="use_old_player_key" translatable="false">use_oldplayer</string>
|
<string name="use_old_player_key" translatable="false">use_oldplayer</string>
|
||||||
<string name="player_gesture_controls_key" translatable="false">player_gesture_controls</string>
|
<string name="player_gesture_controls_key" translatable="false">player_gesture_controls</string>
|
||||||
|
<string name="resume_on_audio_focus_gain_key" translatable="false">resume_on_audio_focus_gain</string>
|
||||||
<string name="default_resolution_key" translatable="false">default_resolution_preference</string>
|
<string name="default_resolution_key" translatable="false">default_resolution_preference</string>
|
||||||
<string name="default_resolution_value" translatable="false">360p</string>
|
<string name="default_resolution_value" translatable="false">360p</string>
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@
|
|||||||
<string name="player_gesture_controls_summary">Use gestures to control the brightness and volume of the player</string>
|
<string name="player_gesture_controls_summary">Use gestures to control the brightness and volume of the player</string>
|
||||||
<string name="show_search_suggestions_title">Search suggestions</string>
|
<string name="show_search_suggestions_title">Search suggestions</string>
|
||||||
<string name="show_search_suggestions_summary">Show suggestions when searching</string>
|
<string name="show_search_suggestions_summary">Show suggestions when searching</string>
|
||||||
|
<string name="resume_on_audio_focus_gain_title">Resume on focus gain</string>
|
||||||
|
<string name="resume_on_audio_focus_gain_summary">Continue playing after interruptions (e.g. phone calls)</string>
|
||||||
|
|
||||||
<string name="download_dialog_title">Download</string>
|
<string name="download_dialog_title">Download</string>
|
||||||
|
|
||||||
|
@ -64,6 +64,12 @@
|
|||||||
android:summary="@string/player_gesture_controls_summary"
|
android:summary="@string/player_gesture_controls_summary"
|
||||||
android:title="@string/player_gesture_controls_title"/>
|
android:title="@string/player_gesture_controls_title"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/resume_on_audio_focus_gain_key"
|
||||||
|
android:summary="@string/resume_on_audio_focus_gain_summary"
|
||||||
|
android:title="@string/resume_on_audio_focus_gain_title"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
Loading…
Reference in New Issue
Block a user