Skip to content

Commit

Permalink
Expose ability to set wake mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Oct 16, 2023
1 parent 1d1dd0e commit 42ab0cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.doublesymmetry.kotlinaudio.models

import com.doublesymmetry.kotlinaudio.players.BaseAudioPlayer

data class PlayerConfig(
/**
* Toggle whether or not a player action triggered from an outside source should be intercepted.
Expand Down Expand Up @@ -30,4 +28,9 @@ data class PlayerConfig(
* The audio content type.
*/
val audioContentType: AudioContentType = AudioContentType.MUSIC,

/**
* The audio usage.
*/
val wakeMode: WakeMode = WakeMode.NONE,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.doublesymmetry.kotlinaudio.models

enum class WakeMode {
NONE,
LOCAL,
NETWORK,
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.doublesymmetry.kotlinaudio.models.PlaybackError
import com.doublesymmetry.kotlinaudio.models.PlayerConfig
import com.doublesymmetry.kotlinaudio.models.PlayerOptions
import com.doublesymmetry.kotlinaudio.models.PositionChangedReason
import com.doublesymmetry.kotlinaudio.models.WakeMode
import com.doublesymmetry.kotlinaudio.notification.NotificationManager
import com.doublesymmetry.kotlinaudio.players.components.PlayerCache
import com.doublesymmetry.kotlinaudio.players.components.getAudioItemHolder
Expand Down Expand Up @@ -220,6 +221,13 @@ abstract class BaseAudioPlayer internal constructor(

exoPlayer = ExoPlayer.Builder(context)
.setHandleAudioBecomingNoisy(playerConfig.handleAudioBecomingNoisy)
.setWakeMode(
when (playerConfig.wakeMode) {
WakeMode.NONE -> C.WAKE_MODE_NONE
WakeMode.LOCAL -> C.WAKE_MODE_LOCAL
WakeMode.NETWORK -> C.WAKE_MODE_NETWORK
}
)
.apply {
if (bufferConfig != null) setLoadControl(setupBuffer(bufferConfig))
}
Expand Down

0 comments on commit 42ab0cb

Please sign in to comment.