pause when unplugging headphones

This commit is contained in:
Bnyro 2022-09-09 18:14:23 +02:00
parent 147d2151a0
commit d354c2b3cc
3 changed files with 4 additions and 1 deletions

View File

@ -46,6 +46,7 @@ class OfflinePlayerActivity : BaseActivity() {
private fun initializePlayer() { private fun initializePlayer() {
player = ExoPlayer.Builder(this) player = ExoPlayer.Builder(this)
.setHandleAudioBecomingNoisy(true)
.build() .build()
playerView = binding.player playerView = binding.player

View File

@ -1315,6 +1315,7 @@ class PlayerFragment : BaseFragment() {
.setMediaSourceFactory(DefaultMediaSourceFactory(dataSourceFactory)) .setMediaSourceFactory(DefaultMediaSourceFactory(dataSourceFactory))
.setLoadControl(loadControl) .setLoadControl(loadControl)
.setTrackSelector(trackSelector) .setTrackSelector(trackSelector)
.setHandleAudioBecomingNoisy(true)
.build() .build()
exoPlayer.setAudioAttributes(audioAttributes, true) exoPlayer.setAudioAttributes(audioAttributes, true)

View File

@ -190,9 +190,10 @@ class BackgroundMode : Service() {
audioAttributes = AudioAttributes.Builder() audioAttributes = AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA) .setUsage(C.USAGE_MEDIA)
.setContentType(C.CONTENT_TYPE_MUSIC) .setContentType(C.AUDIO_CONTENT_TYPE_MUSIC)
.build() .build()
player = ExoPlayer.Builder(this) player = ExoPlayer.Builder(this)
.setHandleAudioBecomingNoisy(true)
.setAudioAttributes(audioAttributes, true) .setAudioAttributes(audioAttributes, true)
.build() .build()