PlayerAdLogicController.java


Overview

`PlayerAdLogicController` is a controller class within the `com.tubitv.media.controller` package designed to manage and coordinate the interactions and logic related to advertisement playback in the media player system of the Tubitv platform. This class acts as a centralized holder and manager for various interfaces and listeners that monitor and control ad playback, cue points, and VPAID (Video Player-Ad Interface Definition) client interactions.

Rather than implementing ad playback logic directly, this controller aggregates several key components related to ad playback logic and exposes getter and setter methods to manipulate these components. This design facilitates decoupling between the ad playback logic and the underlying player and monitoring implementations, enabling flexible integration and testing.


Classes, Methods, and Usage

Class: PlayerAdLogicController

This is the sole class in the file.

Properties (Private Members)

Property

Type

Description

`adPlayingMonitor`

`AdPlayingMonitor`

Listener interface that monitors the current state of ad playback.

`playbackActionCallback`

`PlaybackActionCallback`

Callback interface for playback actions related to ads and media.

`doublePlayerInterface`

`DoublePlayerInterface`

Interface managing two players (possibly separating content and ads).

`cuePointMonitor`

`CuePointMonitor`

Listener for cue points in media playback, typically for triggering ads or other events.

`vpaidClient`

`VpaidClient`

Client interface for handling VPAID ads, allowing interaction with VPAID-compliant ad units.

Constructors

  1. Default Constructor

    public PlayerAdLogicController()
    
    • Initializes an empty controller with all properties set to null.

    • Usage:

      PlayerAdLogicController controller = new PlayerAdLogicController();
      
  2. Constructor without VpaidClient

    public PlayerAdLogicController(@Nullable AdPlayingMonitor adPlayingMonitor,
                                   @Nullable PlaybackActionCallback playbackActionCallback,
                                   @Nullable DoublePlayerInterface doublePlayerInterface,
                                   @Nullable CuePointMonitor cuePointMonitor)
    
    • Initializes the controller with the provided listeners and interfaces except for vpaidClient.

    • Parameters can be null if not available.

    • Usage:

      PlayerAdLogicController controller = new PlayerAdLogicController(adMonitor, playbackCallback, doublePlayer, cuePointMonitor);
      
  3. Constructor with VpaidClient

    public PlayerAdLogicController(@Nullable AdPlayingMonitor adPlayingMonitor,
                                   @Nullable PlaybackActionCallback playbackActionCallback,
                                   @Nullable DoublePlayerInterface doublePlayerInterface,
                                   @Nullable CuePointMonitor cuePointMonitor,
                                   @Nullable VpaidClient vpaidClient)
    
    • Initializes the controller with all provided components, including the VPAID client.

    • Usage:

      PlayerAdLogicController controller = new PlayerAdLogicController(adMonitor, playbackCallback, doublePlayer, cuePointMonitor, vpaidClient);
      

Getters and Setters

Each component has a corresponding getter and setter allowing retrieval and modification:


Important Implementation Details


Interaction with Other System Components

This controller is central to the media player’s ad logic layer, enabling coordination between playback components, ad monitors, and VPAID clients.


Usage Example

// Instantiate monitors and interfaces (implementations omitted for brevity)
AdPlayingMonitor adMonitor = ...;
PlaybackActionCallback playbackCallback = ...;
DoublePlayerInterface doublePlayer = ...;
CuePointMonitor cuePointMonitor = ...;
VpaidClient vpaidClient = ...;

// Create controller with all components
PlayerAdLogicController adLogicController = new PlayerAdLogicController(
    adMonitor,
    playbackCallback,
    doublePlayer,
    cuePointMonitor,
    vpaidClient
);

// Access and interact with components
adLogicController.getAdPlayingMonitor().onAdStarted();
adLogicController.getDoublePlayerInterface().playAd();

Mermaid Class Diagram

classDiagram
    class PlayerAdLogicController {
        - AdPlayingMonitor adPlayingMonitor
        - PlaybackActionCallback playbackActionCallback
        - DoublePlayerInterface doublePlayerInterface
        - CuePointMonitor cuePointMonitor
        - VpaidClient vpaidClient
        + PlayerAdLogicController()
        + PlayerAdLogicController(AdPlayingMonitor, PlaybackActionCallback, DoublePlayerInterface, CuePointMonitor)
        + PlayerAdLogicController(AdPlayingMonitor, PlaybackActionCallback, DoublePlayerInterface, CuePointMonitor, VpaidClient)
        + getAdPlayingMonitor() AdPlayingMonitor
        + setAdPlayingMonitor(AdPlayingMonitor)
        + getTubiPlaybackInterface() PlaybackActionCallback
        + setTubiPlaybackInterface(PlaybackActionCallback)
        + getDoublePlayerInterface() DoublePlayerInterface
        + setDoublePlayerInterface(DoublePlayerInterface)
        + getCuePointMonitor() CuePointMonitor
        + setCuePointMonitor(CuePointMonitor)
        + getVpaidClient() VpaidClient
        + setVpaidClient(VpaidClient)
    }

Summary

`PlayerAdLogicController.java` provides a modular and flexible container for managing the different interfaces and listeners involved in ad playback within the Tubitv media player system. It simplifies the integration of ad playback monitoring, control, and VPAID client communication by serving as a centralized access point for these components. This design aids in maintaining a clean separation of concerns, enabling easier testing, maintenance, and future enhancements related to video advertisement playback logic.