PlaybackInfoProvider

Interface for providing playback timing information.

Used to synchronize audio recording with playback of a backing track. Any playback source (SonixPlayer, custom players, etc.) can implement this interface to provide timing data for recording synchronization.

Usage

// SonixPlayer provides this via asPlaybackInfoProvider
val player = SonixPlayer.create(config)
val recorder = SonixRecorder.create(
SonixRecorderConfig.Builder()
.playbackSyncProvider(player.asPlaybackInfoProvider)
.build()
)

// For custom sources (e.g., YouTube player)
class YouTubePlayerProvider(private val player: YouTubePlayer) : PlaybackInfoProvider {
override val currentTimeMs: Long get() = player.currentTimeMillis.toLong()
override val durationMs: Long get() = player.durationMillis.toLong()
override val isCurrentlyPlaying: Boolean get() = player.isPlaying
}

See also

SonixPlayer.asPlaybackInfoProvider
SonixRecorder

Properties

Link copied to clipboard
abstract val currentTimeMs: Long

Current playback position in milliseconds.

Link copied to clipboard
abstract val durationMs: Long

Total duration of the media in milliseconds.

Link copied to clipboard

Whether playback is currently active.