Media and Ad Models

Purpose

This subtopic addresses the need to represent and manage both media content and advertisements in a unified, structured way. Within the broader scope of media playback and helper utilities, it focuses specifically on modeling the data entities for playable media items and collections of ads. These models encapsulate metadata, playback URLs, and properties that distinguish ads from regular content, enabling seamless handling of diverse media types throughout the playback system.

Functionality

MediaModel

`MediaModel` serves as the fundamental data object representing a single playable media item. It holds essential information such as:

The class provides factory methods to create distinct content or ad media models, ensuring clarity in usage:

public static MediaModel video(String mediaName, String videoUrl, String artworkUrl, String subtitlesUrl) {
    return new MediaModel(mediaName, videoUrl, artworkUrl, subtitlesUrl, null, false, false);
}

public static MediaModel ad(String videoUrl, String clickThroughUrl, boolean isVpaid) {
    return new MediaModel(null, videoUrl, null, null, clickThroughUrl, true, isVpaid);
}

AdMediaModel

`AdMediaModel` wraps a list of `MediaModel` instances representing a sequence or break of ads (commonly known as an Ad Break). It provides utility methods to:

This abstraction is crucial for managing multiple ads as a group and supporting workflows such as preroll, midroll, or postroll ad sequences handled by the FSM player and ad controllers.

Integration and Relationship

`MediaModel` and `AdMediaModel` integrate closely with other media playback and ad management components:

By encapsulating all relevant metadata and playback state in these models, the system achieves a clean separation of concerns, allowing UI components, FSM states, and playback controllers to operate on uniform data structures.

Diagram

The following class diagram illustrates the core structure and relationships between `MediaModel` and `AdMediaModel`:

classDiagram
    class MediaModel {
        - String videoUrl
        - String mediaName
        - String artworkUrl
        - String subtitlesUrl
        - String clickThroughUrl
        - boolean isAd
        - boolean isVpaid
        - MediaSource mediaSource
        + video(mediaName, videoUrl, artworkUrl, subtitlesUrl)
        + ad(videoUrl, clickThroughUrl, isVpaid)
        + getVideoUrl()
        + getMediaName()
        + getArtworkUrl()
        + getSubtitlesUrl()
        + getClickThroughUrl()
        + isAd()
        + isVpaid()
        + getMediaSource()
        + setMediaSource(mediaSource)
    }

    class AdMediaModel {
        - List~MediaModel~ listOfAds
        + nextAD()
        + popFirstAd()
        + nubmerOfAd()
        + getListOfAds()
    }

    AdMediaModel "1" --> "*" MediaModel : contains >

This diagram highlights:

Summary

The Media and Ad Models provide the foundational data abstractions for representing playable video content and advertisements within the media player system. By encapsulating URLs, metadata, and playback flags, these models enable seamless coordination of content and ads, supporting advanced features such as VPAID ad playback and cue point-based ad insertion. Their design facilitates clean integration with FSM playback logic, media source construction, and UI components, enhancing modularity and maintainability.