Skip to main content
ShortKitPlayer is the public interface for observing and controlling playback. You access it through the player property on your ShortKit instance. It exposes state via reactive publishers and accepts commands via direct method calls.
The player follows a unidirectional data flow: state flows down through publishers, commands flow up through methods. You never set state directly.

Publishers

Publishers emit values whenever the corresponding state changes. Subscribe to receive updates, or use the synchronous accessors for one-off reads.
ShortKit uses Combine. Every publisher is typed as AnyPublisher<T, Never> — they never fail.
Store subscriptions in a Set<AnyCancellable>. They are automatically cleaned up when the set is deallocated. Always dispatch to the main queue with .receive(on: DispatchQueue.main) before updating UI.

Publisher reference

Synchronous accessors

For cases where you need a point-in-time read without setting up a subscription, two synchronous accessors are available.
These return the most recent value from the underlying publisher. They do not trigger any side effects.

Commands

Commands are fire-and-forget methods that control playback. The SDK routes each command to the underlying AVPlayer (iOS), ExoPlayer (Android), or native bridge (React Native).

Command reference

Player state machine

The playerState publisher emits one of these values:

Typical transitions

Player event types

PlayerTime

Emitted by the time publisher at ~10 Hz during playback.
Compute progress as a fraction: time.current / time.duration (guard against duration == 0).

LoopEvent

Emitted by the didLoop publisher each time a video restarts from the beginning.

FeedTransitionEvent

Emitted by the feedTransition publisher when the user swipes between feed items.
The began phase fires as soon as the swipe gesture is recognized. The ended phase fires after the collection view settles on the new item. Use began to fade out a custom overlay and ended to configure it for the new item.

FormatChangeEvent

Emitted by the formatChange publisher when the HLS adaptive bitrate algorithm switches variants.

FeedScrollPhase

Emitted by the feedScrollPhase publisher to indicate the scroll state of the feed.

ContentSignal

Passed to sendContentSignal(_:) to influence the recommendation engine.
On Flutter, React Native, and Web, sendContentSignal accepts the string literals 'positive' or 'negative' instead of a typed enum.

Example: custom overlay with state observation

This example builds a minimal custom overlay that shows a play/pause button and a progress bar, driven entirely by the player’s publishers.