Media Selection Interface
Purpose
The Media Selection Interface addresses the need for a simple and flexible entry point to launch media playback sessions with varying content and configurations. Within the broader scope of the Dual Player Activity, it provides users with a straightforward UI to select different video assets, each potentially configured with distinct metadata such as subtitles, artwork, and titles. This interface abstracts the complexity of playback initialization and FSM configuration by encapsulating media selection and intent creation, enabling rapid testing and demonstration of playback capabilities with different media.
Functionality
This subtopic centers around a single activity (`SelectionActivity`) that presents UI elements (buttons) for users to choose video streams to play. Each button is configured with an `OnClickListener` that:
Defines the media metadata — including video URL, subtitle URL (if any), artwork URL, and a descriptive name.
Constructs a
MediaModelinstance representing the selected video and its metadata.Creates an explicit intent targeting the dual ExoPlayer-based playback activity (
DoubleViewTubiPlayerActivity).Passes the
MediaModelas an extra in the intent using the keyTubiPlayerActivity.TUBI_MEDIA_KEY.Starts the playback activity, triggering the FSM and playback UI to initialize with the selected media.
This flow allows the same playback infrastructure to be reused with different media selections, supporting quick switching and testing of multiple content scenarios without modifying playback code.
Code Snippet Illustrating Core Interaction
Intent intent = new Intent(SelectionActivity.this, DoubleViewTubiPlayerActivity.class);
intent.putExtra(TubiPlayerActivity.TUBI_MEDIA_KEY, MediaModel.video(name, VIDEO_URL, artwork, null));
startActivity(intent);
Here, a new playback intent is prepared with a `MediaModel` encapsulating the selected video. This allows the downstream player activity to retrieve and play the media seamlessly.
Integration and Relationship to Parent Topic
The Media Selection Interface acts as a launcher for the Dual Player Activity, which is the parent topic managing dual ExoPlayer instances and FSM-driven playback. By isolating media selection logic into its own activity, the system cleanly separates concerns:
Parent Topic (Dual Player Activity) focuses on playback logic, FSM states, and UI control.
Media Selection Interface focuses solely on media choice and preparation for playback.
This separation enhances modularity and maintainability. Additionally, by passing fully-constructed `MediaModel` instances, it leverages the existing media models and helper utilities defined elsewhere in the project, ensuring consistent media representation across components.
The interface complements other subtopics by providing a reusable entry point that can be easily extended to include more complex selection criteria, playlists, or media source types without modifying the core playback logic.
Diagram: Media Selection to Playback Flow
flowchart TD
A[User taps selection button] --> B[Create MediaModel with metadata]
B --> C[Create Intent with MediaModel extra]
C --> D[Start DoubleViewTubiPlayerActivity]
D --> E[Retrieve MediaModel in player]
E --> F[Initialize FSM with media]
F --> G[Start playback with dual ExoPlayers]
This flowchart visualizes the streamlined process from user media selection through to playback initialization, highlighting how the interface acts as a bridge to the dual player FSM system.