Skip to main content

Initialization Configuration

During initialization, parameters such as autoplay, muted, volume, and loop attributes can be configured. However, it is also possible to modify the volume and muted attributes at a later time, as per requirements.

Media Initialization Configuration

The initialization configuration can set preferred video, caption, and audio behavior when playback starts. These preferences are applied on supported platforms.

AttributeTypeDescription
videoobjectInitial ABR, bitrate, and latency settings.
captionobjectInitial caption display, language, and source settings.
audioobjectInitial audio language settings.
Media Initialization Example
let luraConfig = LuraPlayerConfiguration(
initialization: .init(
video: .init(
abrEnabled: true,
preferredBitrate: 1000000,
latencyMode: .default
),
caption: .init(
enabled: true,
preferredLanguage: "en",
source: ["manifest", "embedded"]
),
audio: .init(
preferredLanguage: "en"
)
)
)

player?.setConfig(luraConfig)
AttributeTypeDescription
initialization.video.abrEnabledBoolEnables or disables ABR on supported platforms.
initialization.video.preferredBitrateIntPreferred starting bitrate on supported platforms.
initialization.video.latencyModeLatencyModePreferred latency mode on initialization.
initialization.caption.enabledBoolShows or hides captions on initialization.
initialization.caption.preferredLanguageStringPreferred caption language on supported platforms.
initialization.caption.source[String]Caption sources to use. Defaults to ["manifest", "embedded"].
initialization.audio.preferredLanguageStringPreferred audio language on supported platforms.

Autoplay Configuration

The implementation of autoplay attribute can be done in Lura Player using the following configuration.

AttributeTypeDescription
autoplaybooleanAutoplay attribute of the player. Defaults to false
Autoplay Example
let player =  try? LuraPlayer(playerView: playerView)
player?.addListener(listener: luraListener)
let lura = Lura(appKey: "APP_KEY", assetId: "ASSET_ID")
let controls = LuraContols()
controls.autoplay = true
let luraConfig = LuraPlayerConfiguration(lura: lura, controls: controls)
player?.setConfig(luraConfig)

Mute Configuration

The implementation of initially muted attribute can be done in Lura Player using the following configuration.

AttributeTypeDescription
mutedbooleanWhether to start muted when the player autoplays. Defaults to false.
info

Some platforms doesn't support unmuted autoplay. So if autoplay attribute is set to true, muted attribute will be overwritten to true in platforms that doesn't support unmuted autoplay.

Mute Example
let player =  try? LuraPlayer(playerView: playerView)
player?.addListener(listener: luraListener)
let lura = Lura(appKey: "APP_KEY", assetId: "ASSET_ID")
let controls = LuraContols()
controls.controls.muted = true
let luraConfig = LuraPlayerConfiguration(lura: lura, controls: controls)
player?.setConfig(luraConfig)

Volume Configuration

The implementation of initial volume attribute can be done in Lura Player using the following configuration.

AttributeTypeDescription
volumenumberInitial volume of the player between 0.0 and 1.0. Defaults to 1.0
Volume Example
let player =  try? LuraPlayer(playerView: playerView)
player?.addListener(listener: luraListener)
let lura = Lura(appKey: "APP_KEY", assetId: "ASSET_ID")
let controls = LuraControls()
controls.volume = 1.0
let luraConfig = LuraPlayerConfiguration(lura: lura, controls: controls)
player?.setConfig(luraConfig)

Loop Configuration

The implementation of loop attribute can be done in Lura Player using the following configuration.

AttributeTypeDescription
loopbooleanLoop the video when it ends. Defaults to false.
Loop Example
let player =  try? LuraPlayer(playerView: playerView)
player?.addListener(listener: luraListener)
let lura = Lura(appKey: "APP_KEY", assetId: "ASSET_ID")
let controls = LuraControls()
controls.loop = true
let luraConfig = LuraPlayerConfiguration(lura: lura, controls: controls)
player?.setConfig(luraConfig)
Combined Example
let player =  try? LuraPlayer(playerView: playerView)
player?.addListener(listener: luraListener)
let lura = Lura(appKey: "APP_KEY", assetId: "ASSET_ID")
let controls = LuraControls()
controls.controls.autoplay = true
controls.controls.muted = true
controls.controls.volume = 1.0
controls.controls.loop = true
let luraConfig = LuraPlayerConfiguration(lura: lura, controls: controls)
player?.setConfig(luraConfig)