mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Merge pull request #4862 from Bnyro/master
feat: option to allow playback during call
This commit is contained in:
commit
7d13aa6849
@ -102,6 +102,7 @@ object PreferenceKeys {
|
||||
const val SB_HIGHLIGHTS = "sb_highlights"
|
||||
const val SHOW_TIME_LEFT = "show_time_left"
|
||||
const val FALLBACK_PIPED_PROXY = "fallback_piped_proxy"
|
||||
const val ALLOW_PLAYBACK_DURING_CALL = "playback_during_call"
|
||||
|
||||
/**
|
||||
* Background mode
|
||||
|
@ -329,6 +329,12 @@ object PlayerHelper {
|
||||
true
|
||||
)
|
||||
|
||||
private val handleAudioFocus
|
||||
get() = !PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.ALLOW_PLAYBACK_DURING_CALL,
|
||||
false
|
||||
)
|
||||
|
||||
fun getDefaultResolution(context: Context, isFullscreen: Boolean): Int? {
|
||||
var prefKey = if (NetworkHelper.isNetworkMetered(context)) {
|
||||
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
|
||||
*/
|
||||
@ -448,6 +444,10 @@ object PlayerHelper {
|
||||
Executors.newCachedThreadPool()
|
||||
)
|
||||
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)
|
||||
.setUsePlatformDiagnostics(false)
|
||||
@ -455,7 +455,7 @@ object PlayerHelper {
|
||||
.setTrackSelector(trackSelector)
|
||||
.setHandleAudioBecomingNoisy(true)
|
||||
.setLoadControl(getLoadControl())
|
||||
.setAudioAttributes(getAudioAttributes(), true)
|
||||
.setAudioAttributes(audioAttributes, handleAudioFocus)
|
||||
.setUsePlatformDiagnostics(false)
|
||||
.build()
|
||||
.apply {
|
||||
|
10
app/src/main/res/drawable/ic_call.xml
Normal file
10
app/src/main/res/drawable/ic_call.xml
Normal 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>
|
@ -447,6 +447,8 @@
|
||||
<string name="remove_watched_videos">Remove watched videos</string>
|
||||
<string name="no_fullscreen_resolution">No-Fullscreen resolution</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 -->
|
||||
<string name="import_subscriptions_from">Import subscriptions from</string>
|
||||
|
@ -198,6 +198,13 @@
|
||||
app:key="pause_screen_off"
|
||||
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>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user