Skip to content

Commit

Permalink
remain in pause after call interruption
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik986arre committed Oct 23, 2024
1 parent f284cc9 commit 41d72df
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class WrappedPlayer internal constructor(

var playing = false
var shouldSeekTo = -1
var playBack = false
var pausePlayback = false

private val focusManager = FocusManager(this)

Expand Down Expand Up @@ -192,11 +194,13 @@ class WrappedPlayer internal constructor(
* Playback handling methods
*/
fun play() {
playBack = true
pausePlayback = false
focusManager.maybeRequestAudioFocus(andThen = ::actuallyPlay)
}

private fun actuallyPlay() {
if (!playing && !released) {
if (!playing && !released && (!pausePlayback || playBack)) {
val currentPlayer = player
playing = true
if (currentPlayer == null) {
Expand All @@ -209,6 +213,8 @@ class WrappedPlayer internal constructor(

fun stop() {
focusManager.handleStop()
pausePlayback = true
playBack = false
if (released) {
return
}
Expand All @@ -230,6 +236,8 @@ class WrappedPlayer internal constructor(
}

fun release() {
pausePlayback = true
playBack = false
focusManager.handleStop()
if (released) {
return
Expand All @@ -247,6 +255,8 @@ class WrappedPlayer internal constructor(
fun pause() {
if (playing) {
playing = false
playBack = false
pausePlayback = true
if (prepared) {
player?.pause()
}
Expand Down

0 comments on commit 41d72df

Please sign in to comment.