BlazeInlinePlayerDelegate
BlazeInlinePlayerDelegate provides handlers for video player events, allowing your app to respond to player lifecycle events, user interactions, and content loading states. It handles events including data loading, player appearance and dismissal, fullscreen transitions, and user interactions with the Blaze inline video player.
Common handlers
The delegate exposes handlers for the following common events. All handlers are optional; set only the ones you need.
onDataLoadStarted: called when content loading beginsonDataLoadComplete: called when content loading finishes (success or failure)onPlayerDidAppear: called when the player appears on screenonPlayerDidDismiss: called when the player is removedonTriggerCTA: called when a call-to-action button is tappedonPlayerDidEnterFullScreen: called when the player enters fullscreen modeonPlayerDidExitFullScreen: called when the player exits fullscreen modeonPlaceholderClicked: called when the placeholder thumbnail is tapped
Example
import UIKit
import BlazeSDK
class VideoViewController: UIViewController {
private var player: BlazeVideosInlinePlayer?
private let containerView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
// Setup container view
view.addSubview(containerView)
containerView.frame = CGRect(x: 0, y: 100, width: view.bounds.width, height: 240)
// Create delegate
let playerDelegate = BlazeInlinePlayerDelegate(
onDataLoadStarted: { [weak self] _ in
self?.showLoading(true)
},
onDataLoadComplete: { [weak self] info in
self?.showLoading(false)
if case .failure(let error) = info.result {
self?.showError(error.localizedDescription)
}
},
onPlayerDidEnterFullScreen: { _ in
print("Player entered fullscreen")
},
onPlayerDidExitFullScreen: { _ in
print("Player exited fullscreen")
}
)
// Create and embed player
player = BlazeVideosInlinePlayer(
playerMode: .interactive(interactivePlyerStyle: .base()),
dataSourceType: .labels(.singleLabel("highlights")),
containerDelegate: playerDelegate,
containerIdentifier: "main-player"
)
player?.embedPlayer(
in: self,
containerView: containerView,
shouldAutoPlayOnStart: true
)
}
private func showLoading(_ isLoading: Bool) {
// Show/hide loading indicator
}
private func showError(_ message: String) {
let alert = UIAlertController(title: "Error", message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default))
present(alert, animated: true)
}
deinit {
player?.remove()
}
}Best practices
- Handle errors and empty states in
onDataLoadCompleteto show appropriate UI - Clean up resources in
deinitby callingplayer?.remove() - Return
truefromonTriggerCTAif your app handles the action, orfalseto let the player handle it
Updated about 2 months ago
What’s Next
Did this page help you?
