diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
index c17a3324d0..3adafd9035 100644
--- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
+++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt
@@ -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
diff --git a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt
index 12a7dd90e7..785017e216 100644
--- a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt
+++ b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt
@@ -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 {
diff --git a/app/src/main/res/drawable/ic_call.xml b/app/src/main/res/drawable/ic_call.xml
new file mode 100644
index 0000000000..1cea46b037
--- /dev/null
+++ b/app/src/main/res/drawable/ic_call.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bd3194f905..80065d3f1e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -447,6 +447,8 @@
Remove watched videos
No-Fullscreen resolution
Same as fullscreen
+ Continue playback during phone call
+ Note that this also affects the app to not handle any kind of audio focus anymore.
Import subscriptions from
diff --git a/app/src/main/res/xml/player_settings.xml b/app/src/main/res/xml/player_settings.xml
index b3b96c6797..db01b46f92 100644
--- a/app/src/main/res/xml/player_settings.xml
+++ b/app/src/main/res/xml/player_settings.xml
@@ -198,6 +198,13 @@
app:key="pause_screen_off"
app:title="@string/pauseOnScreenOff" />
+
+
\ No newline at end of file