Merge pull request #1245 from Bnyro/master

Pause when unplugging headphones
This commit is contained in:
Bnyro 2022-09-09 18:20:39 +02:00 committed by GitHub
commit 1420a8e56f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 4 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()

View File

@ -227,7 +227,7 @@ internal class CustomExoPlayerView(
player?.seekTo((player?.currentPosition ?: 0L) - seekIncrement) player?.seekTo((player?.currentPosition ?: 0L) - seekIncrement)
// show the rewind button // show the rewind button
doubleTapOverlayBinding?.rewindBTN.run { doubleTapOverlayBinding?.rewindBTN.apply {
this!!.visibility = View.VISIBLE this!!.visibility = View.VISIBLE
// clear previous animation // clear previous animation
this.animate().rotation(0F).setDuration(0).start() this.animate().rotation(0F).setDuration(0).start()
@ -252,9 +252,9 @@ internal class CustomExoPlayerView(
// show the forward button // show the forward button
doubleTapOverlayBinding?.forwardBTN.apply { doubleTapOverlayBinding?.forwardBTN.apply {
visibility = View.VISIBLE this!!.visibility = View.VISIBLE
// clear previous animation // clear previous animation
this!!.animate().rotation(0F).setDuration(0).start() this.animate().rotation(0F).setDuration(0).start()
// start new animation // start new animation
this.animate() this.animate()
.rotation(30F) .rotation(30F)