Skip to main content

Initialize

BambuserPlayer.swift
// Import the SDK
import BambuserCommerceSDK

// Initialize the Bambuser video player with the server region
// You can choose between .US or .EU based on your region
let videoPlayer = BambuserVideoPlayer(server: .US) // or .EU

let playerView = videoPlayer.createPlayerView(
videoConfiguration: .init(
type: .live(id: "xxx"),

// List of events to listen to; use ["*"] for all events (currently only option available)
events: ["*"],

// Configuration settings for the player
// More options can be found here:
// https://bambuser.com/docs/live/player-api-reference/
configuration: [
"buttons": [
"dismiss": "none", // Hides the close button on the player.
"product": "none", // Clicking on a product requires a listener for the "should-show-product-view" event to handle this interaction.
],
"actionCard": "none", // Clicking on an action card requires a listener for the "action-card-clicked" event to handle this interaction.
"currency": "USD", // Sets the currency format for display.
"locale": "en-US", // Defines the language and regional settings for the player interface.
"autoplay": true // player will automatically play video when player is ready
]
)
playerView.delegate = self
)

Player Controls

Use play() and pause() to control playback programmatically. These are useful when autoplay is disabled or when you need to respond to app lifecycle events.

// Start or resume playback
playerView.play()

// Pause playback — fires onVideoStatusChanged with .paused
playerView.pause()

For live streams, play() is a no-op if the player is already in .playing state. pause() transitions the player to .paused and fires the onVideoStatusChanged delegate callback.

Player Properties

id

A non-empty string that uniquely identifies this player instance. Use it to distinguish between multiple concurrent players in delegate callbacks.

let playerId: String = playerView.id
print("Player ID: \(playerId)")

currentPlayerState

A BambuserVideoState value reflecting the player's current state. Read this property directly instead of tracking state exclusively through delegate callbacks.

let state: BambuserVideoState = playerView.currentPlayerState

switch state {
case .loading: print("Player is loading")
case .playing: print("Player is playing")
case .paused: print("Player is paused")
case .error: print("Player encountered an error")
default: break
}

Live player state sequence with autoplay: true: .loading.playing

For state change notifications, implement onVideoStatusChanged in your delegate — see Delegate Protocol.