# API Reference

After creating ByteArkPlayerController, you can call the player API directly through the controller instance.

# Lifecycle methods

Method Description
setListener(ByteArkPlayerListener? newListener) Set or change the event listener
attach() Attach the controller to the ByteArkPlayer widget (called automatically when the widget mounts)
detach() Detach the controller (called automatically when the widget unmounts)
dispose() Release the listener and controller resources — call in State.dispose()

# Playback controller

Method Description
play() Start playback
pause() Pause playback
togglePlayback() Toggle play/pause
seekTo(int position) Seek to a position (seconds)
seekForward() Seek forward by the config's seekTime
seekBackward() Seek backward by the config's seekTime

# Playback information

Method Description
getCurrentTime() Current playback time in seconds (returns 0 if not yet available)
currentPosition() Current playback position in seconds
getDuration() Total media duration in seconds (returns 0 if not yet available)

# Media controller

Method Description
switchMediaSource(ByteArkPlayerConfig config) Switch to a new video by passing a new config

# Tracks & quality

Method Description
getAudios() Get the list of available audio tracks
getCurrentAudio() Get the currently selected audio track
setAudio(ByteArkPlayerMediaTrack track) Select an audio track
getSubtitles() Get the list of available subtitle tracks
getCurrentSubtitle() Get the currently selected subtitle track
setSubtitle(ByteArkPlayerMediaTrack? track) Select a subtitle (pass null to disable)
getResolutions() Get the list of available video resolutions
getCurrentResolution() Get the currently selected video resolution
setResolution(ByteArkPlayerMediaTrack track) Select a video resolution

# Playback speed

Method Description
getAvailablePlaybackSpeeds() Get the list of supported playback speeds
getCurrentPlaybackSpeed() Get the current playback speed
setPlaybackSpeed(double speed) Set playback speed (e.g., 0.5, 1.0, 1.5, 2.0)

# UI controller

Method Description
toggleFullScreen() Toggle full-screen mode

# ByteArkPlayerMediaTrack

The audio, subtitle, and resolution getters/setters work with ByteArkPlayerMediaTrack:

Field Type Description
id String? Track identifier
name String? Display name of the track
language String? Track language code