관찰 상태 / 이벤트
컨트롤러는 Compose 구독용 state: StateFlow<PlayerState> 와, 웹 onEvent 에 대응하는 events: SharedFlow<PlayerEvent> 를 제공합니다.
PlayerState 관찰 상태
collectAsStateWithLifecycle() 로 구독합니다.
val state by controller.state.collectAsStateWithLifecycle()
// 재생 상태
state.isPlaying state.currentTime state.duration
state.isReady state.isLive state.isBuffering
state.hasEnded state.isFullscreen state.isPipActive
state.playbackRate state.volume state.muted
state.isCaptureBlocked
// 재생목록
state.currentItem state.playlist state.playIndex
state.canPlayNext state.canPlayPrevious
// 자막
state.availableSubtitles state.activeSubtitleId state.currentSubtitleText
// 라이선스 / 에러
state.lastError state.licenseError state.isLicenseValidated
state.options원시 플레이어는 controller.exoPlayer: ExoPlayer 로 직접 접근할 수 있습니다.
이벤트 구독
raw 이벤트는 events: SharedFlow<PlayerEvent> 로 구독합니다(웹 onEvent 대응).
LaunchedEffect(controller) {
controller.events.collect { event ->
when (event) {
is PlayerEvent.FullscreenChange -> { /* 전체화면 전환 */ }
is PlayerEvent.PictureInPictureChange -> { /* PiP 전환 */ }
is PlayerEvent.Error -> { /* 오류 */ }
else -> {}
}
}
}이벤트 타입
이벤트 타입은 웹 PlayerEvent 스키마와 동일한 의미를 가집니다. 대표적으로 다음과 같습니다.
Ready · Play · Pause · Ended · StateChange
LoadingStart · LoadingEnd · BufferingStart · BufferingEnd
Seeking · Seeked · TimeUpdate · VolumeChange
FullscreenChange · PictureInPictureChange
Next · Prev · SkipForward · SkipBack · PlaylistChange · Error