# API Reference

Once a ByteArkPlayerViewController is created, you can call the Player API through the player instance.

# Configuration methods

Method Description
func configure(with config: ByteArkPlayerConfig) Configure the player with a ByteArkPlayerConfig (built via ByteArkPlayerConfigBuilder)
func destroy() Release the player's resources
func getPlugin(with name: String) -> ByteArkPlayerPlugin? Get a plugin instance by name
func addPlaybackEngineObserve(...) -> any NSObjectProtocol Subscribe to playback-engine notifications

# Playback controller

Method Description
func play() Start playback
func pause() Pause playback
func seek(to time: TimeInterval, completionHandler:) Seek to position (seconds)
func seekForward() Seek forward by the configured seek interval
func seekBackward() Seek backward by the configured seek interval
func seekToLive() Return to the live edge of a DVR live stream (no-op when DVR is inactive; see DVR)
func muted(_ muted: Bool) Mute / unmute
func setVolume(_ volume: Float) Set volume (0.0–1.0)
func setPlaybackSpeed(_ speed: Float) Set playback speed

# UI controller

Method Description
func toggleFullscreen() Toggle fullscreen mode
func togglePictureInPictureMode() Toggle Picture-in-Picture
func enablePictureInPicture() Enable Picture-in-Picture
func disablePictureInPicture() Disable Picture-in-Picture
func showControls() Show the control bar
func hideControls() Hide the control bar

# Background & remote control

Method Description
func enableBackgroundAudio() Enable audio playback while the app is backgrounded
func disableBackgroundAudio() Disable background audio
func enableRemoteControlCenter() Enable control from iOS Control Center
func disableRemoteControlCenter() Disable Control Center integration
func enableInterruptionHandling() Automatically pause/resume across audio-session interruptions (e.g. phone calls)
func disableInterruptionHandling() Disable automatic pause/resume across interruptions

# Tracks & quality

Method Description
func setAudioTrack(_ audioTrack: ByteArkPlayerMediaTrack) Select an audio track
func setSubtitleTrack(_ subtitleTrack: ByteArkPlayerMediaTrack?) Select a subtitle track (pass nil to disable)
func setResolution(_ resolution: ByteArkPlayerMediaResolution) Select a video resolution

# Playlist

Method Description
func next() Skip to the next item in the playlist
func previous() Return to the previous item
func setPlaylistItem(_ playbackItem: ByteArkPlayerItem) throws Set the active playlist item

# Variables

# View hierarchy

Variable Description
var playerContainerView: ByteArkPlayerContainerView { get } Container view holding the rendering view, controls, etc.
var playerViewController: ByteArkPlayerViewController? { get } The player's view controller
var fullscreenViewController: ByteArkPlayerFullscreenViewController? { get } View controller used for fullscreen
var controlsView: UIView? { get } The control-bar view

# Configuration & state

Variable Description
var config: ByteArkPlayerConfig? { get } Config used to create the player
var delegate: ByteArkPlayerPlaybackDelegate? { get, set } Playback delegate
var playbackItem: ByteArkPlayerItem? { get } The currently playing item
var playlist: ByteArkPlayerPlaylist? { get } The active playlist
var error: Error? { get } The current playback error, if any

# Playback info

Variable Description
var currentTime: TimeInterval { get } Current playback time (seconds)
var duration: TimeInterval { get } Duration of the current item (seconds)
var playbackSpeed: Float { get } Current playback speed
var volume: Float { get } Current volume
var presentationSize: CGSize { get } Actual on-screen size of the current rendition (distinct from the selected resolution)
var dvrWindow: DVRWindow? { get } Seekable DVR window of a live stream (nil when DVR is inactive; see DVR)

# Tracks

Variable Description
var audioTrack: ByteArkPlayerMediaTrack? { get } Active audio track
var audioTracks: [ByteArkPlayerMediaTrack] { get } All audio tracks for the current item
var subtitleTrack: ByteArkPlayerMediaTrack? { get } Active subtitle track
var subtitleTracks: [ByteArkPlayerMediaTrack] { get } All subtitle tracks for the current item
var resolution: ByteArkPlayerMediaResolution? { get } Active resolution
var resolutions: [ByteArkPlayerMediaResolution] { get } All resolutions for the current item

# State flags

Variable Description
var isReady: Bool { get } The player is ready to play
var isPlaying: Bool { get } Currently playing
var isSeeking: Bool { get } Seeking
var isBuffering: Bool { get } Buffering
var isEnded: Bool { get } Playback finished
var isMuted: Bool { get } Muted
var isFullscreen: Bool { get } In fullscreen mode
var isInPictureInPicture: Bool { get } In Picture-in-Picture mode
var isDVRActive: Bool { get } DVR (seekable live) playback is active