Player Modes
PlayerMode
The PlayerMode enum defines the visual and behavioral style of the BlazeVideosInlinePlayer and BlazeSwiftUIVideosInlinePlayerView components. It determines how the player appears, how it behaves, and what controls are available to the user.
Choose the right mode for your use caseInteractive mode is ideal for dedicated video viewing areas where users want full control, while Preview mode works best in feeds or lists where a minimal interface is preferred.
Modes
interactive
Declaration
case interactive(
interactivePlyerStyle: BlazeVideosInlineInteractivePlayerStyle,
fullScreenPlayerStyle: BlazeVideosPlayerStyle? = nil
)An inline player with full overlay interaction capabilities. This mode provides comprehensive playback controls directly in the inline view, including play/pause, seek bar, mute, share, and full-screen buttons.
Parameters:
- interactivePlyerStyle: Style configuration for the interactive player mode, controlling the appearance of controls, text, and backgrounds.
- fullScreenPlayerStyle: Optional style configuration for when the player enters fullscreen mode. If not provided, the default style from
Blaze.shared.videosStylewill be used.
Use Case:
Ideal for dedicated video viewing areas where users want full control over playback without necessarily going fullscreen.
Example:
// Create an interactive player with custom styles
// Start with the base style and modify it
var customInteractiveStyle = BlazeVideosInlineInteractivePlayerStyle.base()
customInteractiveStyle.backgroundColor = .black
customInteractiveStyle.headingText.textColor = .white
customInteractiveStyle.headingText.font = .boldSystemFont(ofSize: 16)
customInteractiveStyle.seekBar.isVisible = true
// Create the mode with the customized style
let customInteractiveMode = BlazeVideosInlinePlayer.PlayerMode.interactive(
interactivePlyerStyle: customInteractiveStyle
)preview
Declaration
case preview(
previewPlayerStyle: BlazeVideosInlinePreviewPlayerStyle,
fullScreenPlayerStyle: BlazeVideosPlayerStyle? = nil
)An inline player with minimal overlay visuals. This mode shows a streamlined interface with only essential controls like a mute button. Any interaction outside the minimal buttons will automatically open a full screen player.
Parameters:
- previewPlayerStyle: Style configuration for the preview player mode, controlling the appearance of the minimal controls and overlay.
- fullScreenPlayerStyle: Optional style configuration for when the player enters fullscreen mode. If not provided, the default style from
Blaze.shared.videosStylewill be used.
Use Case:
Perfect for video feeds, lists, or thumbnails where space is limited and a cleaner interface is preferred. Users can quickly tap to view the full experience.
Example:
// Create a preview player with custom styles
// Start with the base style and modify it
var customPreviewStyle = BlazeVideosInlinePreviewPlayerStyle.base()
customPreviewStyle.backgroundColor = .black.withAlphaComponent(0.5)
customPreviewStyle.buttons.mute.color = .white
customPreviewStyle.buttons.mute.isVisible = true
// Create the mode with the customized style
let customPreviewMode = BlazeVideosInlinePlayer.PlayerMode.preview(
previewPlayerStyle: customPreviewStyle,
fullScreenPlayerStyle: .base()
)Usage Examples
With BlazeVideosInlinePlayer
// Create a player with interactive mode
let player = BlazeVideosInlinePlayer(
playerMode: .interactive(interactivePlyerStyle: .base()),
dataSourceType: .labels(.singleLabel("highlights")),
containerIdentifier: "main-player"
)
// Create a player with preview mode
let previewPlayer = BlazeVideosInlinePlayer(
playerMode: .preview(previewPlayerStyle: .base()),
dataSourceType: .labels(.singleLabel("highlights")),
containerIdentifier: "feed-player"
)With BlazeSwiftUIVideosInlinePlayerView
// Interactive player in SwiftUI
BlazeSwiftUIVideosInlinePlayerView(
playerMode: .interactive(interactivePlyerStyle: .base()),
dataSourceType: .labels(.singleLabel("highlights")),
embeddedState: .player(autoPlayOnStart: true),
containerIdentifier: "main-player"
)
// Preview player in SwiftUI
BlazeSwiftUIVideosInlinePlayerView(
playerMode: .preview(previewPlayerStyle: .base()),
dataSourceType: .labels(.singleLabel("highlights")),
embeddedState: .placeholder,
containerIdentifier: "feed-player-1"
)Updated about 2 months ago
