Sonix Player Config
data class SonixPlayerConfig(val volume: Float = 1.0f, val pitch: Float = 0.0f, val tempo: Float = 1.0f, val loopCount: Int = 1, val onComplete: () -> Unit? = null, val onLoopComplete: (loopIndex: Int, totalLoops: Int) -> Unit? = null, val onPlaybackStateChanged: (isPlaying: Boolean) -> Unit? = null, val onError: (message: String) -> Unit? = null)
Configuration for SonixPlayer.
Usage Tiers
Tier 1: Presets (80% of users)
Kotlin
val player = SonixPlayer.create("song.mp3", SonixPlayerConfig.DEFAULT)Content copied to clipboard
Swift
let player = try await SonixPlayer.create(source: "song.mp3", config: .default)Content copied to clipboard
Tier 2: Builder (15% of users)
Kotlin
val config = SonixPlayerConfig.Builder()
.preset(SonixPlayerConfig.LOOPING)
.volume(0.8f)
.pitch(-2f)
.build()
val player = SonixPlayer.create("song.mp3", config)Content copied to clipboard
Swift
let config = SonixPlayerConfig.Builder()
.preset(.looping)
.volume(0.8)
.pitch(-2)
.build()
let player = try await SonixPlayer.create(source: "song.mp3", config: config)Content copied to clipboard
Tier 3: .copy() (5% of users)
Kotlin
val config = SonixPlayerConfig.LOOPING.copy(volume = 0.5f)Content copied to clipboard
See also
Factory method to create players
For recording audio
Constructors
Link copied to clipboard
constructor(volume: Float = 1.0f, pitch: Float = 0.0f, tempo: Float = 1.0f, loopCount: Int = 1, onComplete: () -> Unit? = null, onLoopComplete: (loopIndex: Int, totalLoops: Int) -> Unit? = null, onPlaybackStateChanged: (isPlaying: Boolean) -> Unit? = null, onError: (message: String) -> Unit? = null)