Merge pull request #4862 from Bnyro/master

feat: option to allow playback during call
This commit is contained in:
Bnyro 2023-09-26 13:32:33 +02:00 committed by GitHub
commit 7d13aa6849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 11 deletions

View File

@ -102,6 +102,7 @@ object PreferenceKeys {
const val SB_HIGHLIGHTS = "sb_highlights" const val SB_HIGHLIGHTS = "sb_highlights"
const val SHOW_TIME_LEFT = "show_time_left" const val SHOW_TIME_LEFT = "show_time_left"
const val FALLBACK_PIPED_PROXY = "fallback_piped_proxy" const val FALLBACK_PIPED_PROXY = "fallback_piped_proxy"
const val ALLOW_PLAYBACK_DURING_CALL = "playback_during_call"
/** /**
* Background mode * Background mode

View File

@ -329,6 +329,12 @@ object PlayerHelper {
true true
) )
private val handleAudioFocus
get() = !PreferenceHelper.getBoolean(
PreferenceKeys.ALLOW_PLAYBACK_DURING_CALL,
false
)
fun getDefaultResolution(context: Context, isFullscreen: Boolean): Int? { fun getDefaultResolution(context: Context, isFullscreen: Boolean): Int? {
var prefKey = if (NetworkHelper.isNetworkMetered(context)) { var prefKey = if (NetworkHelper.isNetworkMetered(context)) {
PreferenceKeys.DEFAULT_RESOLUTION_MOBILE PreferenceKeys.DEFAULT_RESOLUTION_MOBILE
@ -428,16 +434,6 @@ object PlayerHelper {
} }
} }
/**
* Get the audio attributes to use for the player
*/
fun getAudioAttributes(): AudioAttributes {
return AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA)
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
.build()
}
/** /**
* Create a basic player, that is used for all types of playback situations inside the app * Create a basic player, that is used for all types of playback situations inside the app
*/ */
@ -448,6 +444,10 @@ object PlayerHelper {
Executors.newCachedThreadPool() Executors.newCachedThreadPool()
) )
val dataSourceFactory = DefaultDataSource.Factory(context, cronetDataSourceFactory) val dataSourceFactory = DefaultDataSource.Factory(context, cronetDataSourceFactory)
val audioAttributes = AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA)
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
.build()
return ExoPlayer.Builder(context) return ExoPlayer.Builder(context)
.setUsePlatformDiagnostics(false) .setUsePlatformDiagnostics(false)
@ -455,7 +455,7 @@ object PlayerHelper {
.setTrackSelector(trackSelector) .setTrackSelector(trackSelector)
.setHandleAudioBecomingNoisy(true) .setHandleAudioBecomingNoisy(true)
.setLoadControl(getLoadControl()) .setLoadControl(getLoadControl())
.setAudioAttributes(getAudioAttributes(), true) .setAudioAttributes(audioAttributes, handleAudioFocus)
.setUsePlatformDiagnostics(false) .setUsePlatformDiagnostics(false)
.build() .build()
.apply { .apply {

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M20.01,15.38c-1.23,0 -2.42,-0.2 -3.53,-0.56 -0.35,-0.12 -0.74,-0.03 -1.01,0.24l-1.57,1.97c-2.83,-1.35 -5.48,-3.9 -6.89,-6.83l1.95,-1.66c0.27,-0.28 0.35,-0.67 0.24,-1.02 -0.37,-1.11 -0.56,-2.3 -0.56,-3.53 0,-0.54 -0.45,-0.99 -0.99,-0.99H4.19C3.65,3 3,3.24 3,3.99 3,13.28 10.73,21 20.01,21c0.71,0 0.99,-0.63 0.99,-1.18v-3.45c0,-0.54 -0.45,-0.99 -0.99,-0.99z" />
</vector>

View File

@ -447,6 +447,8 @@
<string name="remove_watched_videos">Remove watched videos</string> <string name="remove_watched_videos">Remove watched videos</string>
<string name="no_fullscreen_resolution">No-Fullscreen resolution</string> <string name="no_fullscreen_resolution">No-Fullscreen resolution</string>
<string name="same_as_fullscreen">Same as fullscreen</string> <string name="same_as_fullscreen">Same as fullscreen</string>
<string name="playback_during_call">Continue playback during phone call</string>
<string name="playback_during_call_summary">Note that this also affects the app to not handle any kind of audio focus anymore.</string>
<!-- Backup & Restore Settings --> <!-- Backup & Restore Settings -->
<string name="import_subscriptions_from">Import subscriptions from</string> <string name="import_subscriptions_from">Import subscriptions from</string>

View File

@ -198,6 +198,13 @@
app:key="pause_screen_off" app:key="pause_screen_off"
app:title="@string/pauseOnScreenOff" /> app:title="@string/pauseOnScreenOff" />
<SwitchPreferenceCompat
android:icon="@drawable/ic_call"
android:summary="@string/playback_during_call_summary"
app:defaultValue="false"
app:key="playback_during_call"
app:title="@string/playback_during_call" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>