GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

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 begins
  • onDataLoadComplete: called when content loading finishes (success or failure)
  • onPlayerDidAppear: called when the player appears on screen
  • onPlayerDidDismiss: called when the player is removed
  • onTriggerCTA: called when a call-to-action button is tapped
  • onPlayerDidEnterFullScreen: called when the player enters fullscreen mode
  • onPlayerDidExitFullScreen: called when the player exits fullscreen mode
  • onPlaceholderClicked: 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 onDataLoadComplete to show appropriate UI
  • Clean up resources in deinit by calling player?.remove()
  • Return true from onTriggerCTA if your app handles the action, or false to let the player handle it

Did this page help you?