VideoPlayerState

@UnstableApi
@Stable
actual open class VideoPlayerState
@Stable
expect open class VideoPlayerState

Represents the state and controls for a video player. This class provides properties and methods to manage video playback, including play, pause, stop, seeking, and more. It maintains information about the playback state, such as whether the video is currently playing, volume levels, and playback position.

Functions of this class are tied to managing and interacting with the underlying video player implementation.

@Stable
actual open class VideoPlayerState
@Stable
actual open class VideoPlayerState

Represents the state and behavior of a video player. This class provides properties and methods to control video playback, manage the playback state, and interact with platform-specific implementations.

The actual implementation delegates its behavior to platform-specific video player states based on the detected operating system. Supported platforms include Windows, macOS, and Linux.

Properties:

  • isPlaying: Indicates whether the video is currently playing.

  • volume: Controls the playback volume. Valid values are within the range of 0.0 (muted) to 1.0 (maximum volume).

  • sliderPos: Represents the current playback position as a normalized value between 0.0 and 1.0.

  • userDragging: Denotes whether the user is manually adjusting the playback position.

  • loop: Specifies if the video should loop when it reaches the end.

  • leftLevel: Provides the audio level for the left channel as a percentage.

  • rightLevel: Provides the audio level for the right channel as a percentage.

  • positionText: Returns the current playback position as a formatted string.

  • durationText: Returns the total duration of the video as a formatted string.

Methods:

  • openUri(uri: String): Opens a video file or URL for playback.

  • play(): Starts or resumes video playback.

  • pause(): Pauses video playback.

  • stop(): Stops playback and resets the player state.

  • seekTo(value: Float): Seeks to a specific playback position based on the provided normalized value.

  • dispose(): Releases resources used by the video player and disposes of the state.

@Stable
actual open class VideoPlayerState

Implementation of VideoPlayerState for WebAssembly/JavaScript platform. Manages the state of a video player including playback controls, media information, and error handling.

Constructors

Link copied to clipboard
constructor()
expect constructor()

Initializes an instance of the video player state.

constructor()
constructor()
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var applyPlaybackSpeedCallback: (Float) -> Unit?

Callback to apply playback speed changes to the underlying media player

Link copied to clipboard
var applyVolumeCallback: (Float) -> Unit?

Callback to apply volume changes to the underlying media player

Link copied to clipboard
actual val aspectRatio: Float
expect val aspectRatio: Float
actual val aspectRatio: Float
actual open val aspectRatio: Float
actual val aspectRatio: Float
Link copied to clipboard
actual val availableSubtitleTracks: MutableList<SubtitleTrack>
expect val availableSubtitleTracks: MutableList<SubtitleTrack>
actual val availableSubtitleTracks: MutableList<SubtitleTrack>
actual val availableSubtitleTracks: MutableList<SubtitleTrack>
actual val availableSubtitleTracks: MutableList<SubtitleTrack>
Link copied to clipboard
actual var currentSubtitleTrack: SubtitleTrack?
actual var currentSubtitleTrack: SubtitleTrack?
Link copied to clipboard
actual val currentTime: Double
expect val currentTime: Double
actual val currentTime: Double
actual open val currentTime: Double
actual val currentTime: Double
Link copied to clipboard
Link copied to clipboard
actual val durationText: String
expect val durationText: String
actual val durationText: String
actual open val durationText: String
actual val durationText: String
Link copied to clipboard
actual val error: VideoPlayerError?
expect val error: VideoPlayerError?
actual val error: VideoPlayerError? = null
actual open val error: VideoPlayerError?
actual val error: VideoPlayerError?
Link copied to clipboard
actual val hasMedia: Boolean
expect val hasMedia: Boolean
actual val hasMedia: Boolean
actual open val hasMedia: Boolean
actual val hasMedia: Boolean
Link copied to clipboard
actual var isFullscreen: Boolean
expect var isFullscreen: Boolean
actual var isFullscreen: Boolean
actual open var isFullscreen: Boolean
actual var isFullscreen: Boolean
Link copied to clipboard
actual val isLoading: Boolean
expect val isLoading: Boolean
actual val isLoading: Boolean
actual open val isLoading: Boolean
actual val isLoading: Boolean
Link copied to clipboard
actual val isPlaying: Boolean
expect val isPlaying: Boolean
actual val isPlaying: Boolean
actual open val isPlaying: Boolean
actual val isPlaying: Boolean
Link copied to clipboard
actual val leftLevel: Float
expect val leftLevel: Float
actual val leftLevel: Float = 0.0f
actual open val leftLevel: Float
actual val leftLevel: Float
Link copied to clipboard
actual var loop: Boolean
expect var loop: Boolean
actual var loop: Boolean
actual open var loop: Boolean
actual var loop: Boolean
Link copied to clipboard
actual val metadata: VideoMetadata
actual open val metadata: VideoMetadata
actual val metadata: VideoMetadata
Link copied to clipboard
actual var playbackSpeed: Float
expect var playbackSpeed: Float
actual var playbackSpeed: Float
actual open var playbackSpeed: Float
actual var playbackSpeed: Float
Link copied to clipboard
var player: AVPlayer?
Link copied to clipboard

Callback function to force recalculation of the HTML view position. This is set by the VideoPlayerSurface when the HTML view is created.

Link copied to clipboard
actual val positionText: String
expect val positionText: String
actual val positionText: String
actual open val positionText: String
actual val positionText: String
Link copied to clipboard
actual val rightLevel: Float
expect val rightLevel: Float
actual val rightLevel: Float = 0.0f
actual open val rightLevel: Float
actual val rightLevel: Float
Link copied to clipboard
actual var sliderPos: Float
expect var sliderPos: Float
actual var sliderPos: Float
actual open var sliderPos: Float
actual var sliderPos: Float
Link copied to clipboard
val sourceUri: String?
Link copied to clipboard
actual var subtitleBackgroundColor: Color
expect var subtitleBackgroundColor: Color
actual var subtitleBackgroundColor: Color
actual var subtitleBackgroundColor: Color
actual var subtitleBackgroundColor: Color
Link copied to clipboard
actual var subtitlesEnabled: Boolean
expect var subtitlesEnabled: Boolean
actual var subtitlesEnabled: Boolean
actual var subtitlesEnabled: Boolean
actual var subtitlesEnabled: Boolean
Link copied to clipboard
actual var subtitleTextStyle: TextStyle
expect var subtitleTextStyle: TextStyle
actual var subtitleTextStyle: TextStyle
actual var subtitleTextStyle: TextStyle
actual var subtitleTextStyle: TextStyle
Link copied to clipboard
actual var userDragging: Boolean
expect var userDragging: Boolean
actual var userDragging: Boolean
actual open var userDragging: Boolean
actual var userDragging: Boolean
Link copied to clipboard
val videoAspectRatio: CGFloat
Link copied to clipboard
actual var volume: Float
expect var volume: Float
actual var volume: Float
actual open var volume: Float
actual var volume: Float

Functions

Link copied to clipboard
actual fun clearError()
expect fun clearError()
actual fun clearError()
actual open fun clearError()
actual fun clearError()

Clears any error state.

Link copied to clipboard
actual fun disableSubtitles()
expect fun disableSubtitles()
actual fun disableSubtitles()

Disables subtitle display.

actual fun disableSubtitles()
actual fun disableSubtitles()

Disables subtitles by clearing the current track and setting subtitlesEnabled to false.

Link copied to clipboard
actual fun dispose()
expect fun dispose()
actual fun dispose()
actual open fun dispose()
actual fun dispose()

Disposes of resources used by the player.

Link copied to clipboard

Forces recalculation of the HTML view position. This is useful when the layout changes and the HTML view needs to be repositioned.

Link copied to clipboard
fun onTimeUpdate(currentTime: Float, duration: Float, forceUpdate: Boolean = false)

Callback for time update events from the media player.

Link copied to clipboard
actual fun openFile(file: PlatformFile, initializeplayerState: InitialPlayerState)
expect fun openFile(file: PlatformFile, initializeplayerState: InitialPlayerState = InitialPlayerState.PLAY)
actual fun openFile(file: PlatformFile, initializeplayerState: InitialPlayerState)
actual open fun openFile(file: PlatformFile, initializeplayerState: InitialPlayerState)
actual fun openFile(file: PlatformFile, initializeplayerState: <Error class: unknown class>)

Opens a media file.

Link copied to clipboard
actual fun openUri(uri: String, initializeplayerState: InitialPlayerState)
expect fun openUri(uri: String, initializeplayerState: InitialPlayerState = InitialPlayerState.PLAY)
actual fun openUri(uri: String, initializeplayerState: InitialPlayerState)

Opens a media source from the given URI.

actual open fun openUri(uri: String, initializeplayerState: InitialPlayerState)
actual fun openUri(uri: String, initializeplayerState: <Error class: unknown class>)

Opens a media source from the given URI.

Link copied to clipboard
actual fun pause()
expect fun pause()
actual fun pause()
actual open fun pause()
actual fun pause()

Pauses playback of the current media.

Link copied to clipboard
actual fun play()
expect fun play()
actual fun play()
actual open fun play()
actual fun play()

Starts or resumes playback of the current media. If no media is loaded but a previous URI exists, reopens that media.

Link copied to clipboard
actual fun seekTo(value: Float)
expect fun seekTo(value: Float)
actual fun seekTo(value: Float)
actual open fun seekTo(value: Float)
actual fun seekTo(value: Float)

Seeks to a specific position in the media.

Link copied to clipboard
actual fun selectSubtitleTrack(track: SubtitleTrack?)

Selects a subtitle track for display. If track is null, disables subtitles.

actual fun selectSubtitleTrack(track: <Error class: unknown class>?)

Selects a subtitle track and enables subtitles.

Link copied to clipboard
fun setError(error: <Error class: unknown class>)

Sets the error state.

Link copied to clipboard
actual fun stop()
expect fun stop()
actual fun stop()
actual open fun stop()
actual fun stop()

Stops playback and resets the player state. Note: lastUri is preserved for potential replay.

Link copied to clipboard
actual fun toggleFullscreen()
expect fun toggleFullscreen()
actual fun toggleFullscreen()

Toggles the fullscreen state of the video player

actual open fun toggleFullscreen()
actual fun toggleFullscreen()

Toggles the fullscreen state of the video player

Link copied to clipboard
fun updateAudioLevels(left: Float, right: Float)

Updates the audio level indicators.

Link copied to clipboard
fun updatePosition(currentTime: Float, duration: Float, forceUpdate: Boolean = false)

Updates the position and duration display.