Package com.castlabs.sdk.broadpeak

# Class BroadpeakComponent

java.lang.Object
com.castlabs.sdk.broadpeak.BroadpeakComponent

All Implemented Interfaces:
  `PlayerControllerPlugin.Component`

public final class BroadpeakComponent extends Object implements PlayerControllerPlugin.Component
Broadpeak player component.

To get an instance of this class, use `PlayerController.getComponent(Class)`.

Since:
  4.2.32

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addAdDataListener(tv.broadpeak.smartlib.ad.AdManager.AdDataListener listener)`
  Registers a listener that receives Broadpeak ad data updates.
  `void`
  `addAdEventsListener(tv.broadpeak.smartlib.ad.AdManager.AdEventsListener listener)`
  Registers a Broadpeak ad events listener.
  `void`
  `adUserInteraction(String interaction)`
  Notifies Broadpeak about an ad user interaction event.
  `AdApi`
  `getAdApi()`
  Exposes the current Broadpeak `AdApi` instance, if one is available.
  `List<tv.broadpeak.smartlib.ad.AdBreakData>`
  `getAdBreaks()`
  Returns the list of known Broadpeak ad breaks for the active session.
  `Ad`
  `getCurrentAd()`
  Provides the ad currently being rendered by Broadpeak.
  `long`
  `getPositionForBookmark()`
  Calculates the position that should be used to create a bookmark.
  `long`
  `getPositionForPlayback(long bookmarkPositionMs)`
  Normalizes the playback position that should be used when resuming from a bookmark.
  `Class`
  `id()`
  `void`
  `onDestroy(PlayerController playerController)`
  `void`
  `onOpenBundle(PlayerController playerController, Bundle bundle)`
  `void`
  `onOpenState(PlayerController playerController, PlayerConfig playerConfig)`
  `void`
  `removeAdDataListener(tv.broadpeak.smartlib.ad.AdManager.AdDataListener listener)`
  Unregisters a previously added Broadpeak ad data listener.
  `void`
  `removeAdEventsListener(tv.broadpeak.smartlib.ad.AdManager.AdEventsListener listener)`
  Removes a previously registered Broadpeak ad events listener.
  `void`
  `setAdParameter(String name, String value)`
  Adds or overrides a Broadpeak ad parameter for the current session.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### id

    @NonNull public Class id()
    Specified by:
      `id` in interface `PlayerControllerPlugin.Component`

  - ### onDestroy

    public void onDestroy(@NonNull PlayerController playerController)
    Specified by:
      `onDestroy` in interface `PlayerControllerPlugin.Component`

  - ### onOpenBundle

    public void onOpenBundle(@NonNull PlayerController playerController, @NonNull Bundle bundle)
    Specified by:
      `onOpenBundle` in interface `PlayerControllerPlugin.Component`

  - ### onOpenState

    public void onOpenState(PlayerController playerController, PlayerConfig playerConfig)
    Specified by:
      `onOpenState` in interface `PlayerControllerPlugin.Component`

  - ### getAdApi

    @Nullable public AdApi getAdApi()
    Exposes the current Broadpeak `AdApi` instance, if one is available.
    Returns:
      the active Broadpeak ad API or null when ads are not in use

  - ### getCurrentAd

    @Nullable public Ad getCurrentAd()
    Provides the ad currently being rendered by Broadpeak.
    Returns:
      the current ad or null if no ad is active

  - ### getAdBreaks

    @NonNull public List<tv.broadpeak.smartlib.ad.AdBreakData> getAdBreaks()
    Returns the list of known Broadpeak ad breaks for the active session.
    Returns:
      an immutable snapshot of the available ad breaks

  - ### setAdParameter

    public void setAdParameter(@NonNull String name, @NonNull String value)
    Adds or overrides a Broadpeak ad parameter for the current session.
    Parameters:
      `name` - the Broadpeak parameter key
      `value` - the Broadpeak parameter value

  - ### adUserInteraction

    public void adUserInteraction(@NonNull String interaction)
    Notifies Broadpeak about an ad user interaction event.
    Parameters:
      `interaction` - the interaction identifier coming from the host app

  - ### getPositionForBookmark

    public long getPositionForBookmark()
    Calculates the position that should be used to create a bookmark. Returns -1 if there's no ongoing session.
    Returns:
      the bookmark playback position in milliseconds

  - ### getPositionForPlayback

    public long getPositionForPlayback(long bookmarkPositionMs)
    Normalizes the playback position that should be used when resuming from a bookmark.
    Parameters:
      `bookmarkPositionMs` - the stored bookmark position in milliseconds
    Returns:
      the adjusted playback position in milliseconds

  - ### addAdEventsListener

    public void addAdEventsListener(@NonNull tv.broadpeak.smartlib.ad.AdManager.AdEventsListener listener)
    Registers a Broadpeak ad events listener.
    Parameters:
      `listener` - the listener to add

  - ### removeAdEventsListener

    public void removeAdEventsListener(@NonNull tv.broadpeak.smartlib.ad.AdManager.AdEventsListener listener)
    Removes a previously registered Broadpeak ad events listener.
    Parameters:
      `listener` - the listener to remove

  - ### addAdDataListener

    public void addAdDataListener(@NonNull tv.broadpeak.smartlib.ad.AdManager.AdDataListener listener)
    Registers a listener that receives Broadpeak ad data updates.
    Parameters:
      `listener` - the listener to add

  - ### removeAdDataListener

    public void removeAdDataListener(@NonNull tv.broadpeak.smartlib.ad.AdManager.AdDataListener listener)
    Unregisters a previously added Broadpeak ad data listener.
    Parameters:
      `listener` - the listener to remove