Playback Controls
Observing if the video is playing
Note: The playback should have already started before making any interactions
To observe the video is currently playing, The following can be used:
viewModelScope.launch {
client.isPlaying.collectLatest { isPlaying ->
// isPlaying will be set to true if the video is currently in play state.
}
}
Observing Current Playback Time
Note: The playback should have already started before making any interactions
To observe the current playback time, The following can be used:
viewModelScope.launch {
client.currentTime.collectLatest { time ->
// This will trigger every seconds to indicate the new time.
}
}
Seeking to a specific time
Note: The playback should have already started before making any interactions
To seek to a specific time, The following can be used:
client.seek(start = 123123123L)
Resume playback
Note: The playback should have already started before making any interactions
To resume playback, The following can be used:
client.play()
Pause playback
Note: The playback should have already started before making any interactions
To Pause playback, The following can be used:
client.pause()
Switching the sensor being played back
On a multi-lens camera (device.sensors()), to switch the lens being played back, The following can be used:
client.switchSensor(lensId = "0")
End of footage
The camera reports the end of available footage on two flows; watch both and stop the scrubber:
viewModelScope.launch {
client.playbackEnded.collectLatest { ended -> }
}
viewModelScope.launch {
client.noMorePlaybackData.collectLatest { noMore -> }
}
seeking is true while a seek awaits the camera’s acknowledgement; playing and pausing reflect the last command the camera acknowledged (pausing is also raised as soon as pause() is called), and both clear on the next seek ack. resetSeekQueue() drops queued seeks when the user scrubs quickly. keepAlive() sends a wake-up message to battery cameras (device.hasBattery()) so they do not sleep during playback; it does nothing on mains-powered cameras.
playbackEnded is only raised on firmware v2+ and is cleared on every seek; noMorePlaybackData is cleared on the next seek ack. switchSensor also re-requests media info for the current hour, which resets timeLine.