val player = VideoPlayer(
source = VideoSource.Url("https://example.com/video.mp4"),
codec = VideoCodec.MP4,
)
// Observe state changes
scope.launch {
player.state.collect { state ->
when (state) {
VideoPlayerState.PLAYING -> showPlayingUI()
VideoPlayerState.ENDED -> showCompletedUI()
else -> { /* handle other states */}
}
}
}
// Send content and start playback
display.sendContent { video(player = player) }
player.play()
class VideoPlayer(val source: VideoSource, val codec: VideoCodec)
VideoPlayer
(
source
, codec
)
|
codec
: VideoCodec
[Get] |
The codec format of the video data.
Signature
val codec: VideoCodec |
error
: StateFlow<VideoPlayerError?>
[Get] |
The most recent error, or null if no error has occurred.
Collect this flow to react to playback errors. The value is reset to null when a new playback operation starts successfully.
Signature
val error: StateFlow<VideoPlayerError?> |
source
: VideoSource
[Get] |
The video data source (URL, byte array, or stream).
Signature
val source: VideoSource |
state
: StateFlow<VideoPlayerState>
[Get] |
The current playback state of this player.
State transitions:
Signature
val state: StateFlow<VideoPlayerState> |
close
()
|
Stops playback and releases resources associated with this player.
After calling close(), the player transitions to VideoPlayerState.IDLE. This is a terminal state — the player cannot be restarted. Create a new VideoPlayer instance for subsequent playback.
Signature
fun close() |
play
()
|
Starts video playback on the wearable display.
The player must first be bound to a display by passing it to video() inside sendContent. Calling play() before binding emits VideoPlayerError.NOT_BOUND.
Signature
fun play() |