-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlayerSessionState.kt
30 lines (26 loc) · 1.1 KB
/
PlayerSessionState.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.player.session
import android.os.Bundle
import ch.srgssr.pillarbox.player.PillarboxPlayer
/**
* The player state that is bundled as media session extras for each connected controller.
*/
internal data class PlayerSessionState(val smoothSeekingEnabled: Boolean, val trackingEnabled: Boolean) {
constructor(extras: Bundle) : this(
smoothSeekingEnabled = extras.getBoolean(PillarboxSessionCommands.SMOOTH_SEEKING_ARG),
trackingEnabled = extras.getBoolean(PillarboxSessionCommands.TRACKER_ENABLED_ARG),
)
constructor(player: PillarboxPlayer) : this(
smoothSeekingEnabled = player.smoothSeekingEnabled,
trackingEnabled = player.trackingEnabled,
)
fun toBundle(bundle: Bundle = Bundle.EMPTY): Bundle {
return Bundle(bundle).apply {
putBoolean(PillarboxSessionCommands.SMOOTH_SEEKING_ARG, smoothSeekingEnabled)
putBoolean(PillarboxSessionCommands.TRACKER_ENABLED_ARG, trackingEnabled)
}
}
}