Skip to main content

BBNativePlayer

struct BBNativePlayer: View

A SwiftUI wrapper for BBNativePlayerView.

Embeds the Blue Billywig native video player in a SwiftUI layout. Observe the player's reactive state via BBPlayerState and control it with its methods.

Minimal usage (fire-and-forget, auto-cleanup)

BBNativePlayer(jsonUrl: "https://demo.bbvms.com/p/default/c/4256635.json")
.aspectRatio(16/9, contentMode: .fit)

Full control

struct VideoScreen: View {
@State private var playerState = BBPlayerState()

var body: some View {
BBNativePlayer(
jsonUrl: "https://demo.bbvms.com/p/default/c/4256635.json",
state: playerState
)
.aspectRatio(16/9, contentMode: .fit)
.onDisappear { playerState.destroy() }
}
}

Important: The jsonUrl is only read when the view first appears. To switch content after the player is initialized, use the load methods on BBPlayerState (e.g. BBPlayerState/loadClip(id:autoPlay:seekTo:context:)).

Important: When using the init(jsonUrl:options:state:) initializer, call BBPlayerState/destroy() from .onDisappear to ensure timely cleanup. The convenience init(jsonUrl:options:) handles this automatically.