package cn.learningpad.oraltrainer.sdk

data class PlaybackSnapshot(
    val mediaId: String?,
    val positionMs: Long,
    val durationMs: Long,
    val bufferedPositionMs: Long,
    val isPlaying: Boolean,
    val playbackState: OralTrainerPlaybackState,
    val playbackSpeed: Float,
    val sentenceIndex: Int?,
)

enum class OralTrainerPlaybackState {
    IDLE,
    BUFFERING,
    READY,
    ENDED,
}

data class GestureEvent(
    val kind: GestureKind,
    val action: SwipeAction? = null,
)

enum class GestureKind {
    SINGLE_TAP,
    SWIPE_LEFT,
    SWIPE_RIGHT,
    LONG_PRESS_SPEED,
}

interface OralTrainerListener {
    fun onPlaybackSnapshot(snapshot: PlaybackSnapshot) = Unit

    fun onMediaChanged(item: TrainingMediaItem?) = Unit

    fun onSentenceChanged(sentence: SentenceBoundary?) = Unit

    fun onGesture(event: GestureEvent) = Unit

    fun onPlayerError(error: Throwable) = Unit
}
