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() {
player = ExoPlayer.Builder(this)
.setHandleAudioBecomingNoisy(true)
.build()
playerView = binding.player

View File

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

View File

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

View File

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