SelectionActivity.java


Overview

`SelectionActivity` is a simple Android `Activity` that serves as a media selection interface within the Tubi TV media demo application. Its primary purpose is to present users with options to select video content and launch a specialized dual-player playback activity (`DoubleViewTubiPlayerActivity`) to play the selected media.

It provides two buttons, each mapped to a different video asset, which when clicked:

This file acts as an entry point for demonstrating and testing playback capabilities with different video sources, leveraging the dual ExoPlayer setup handled by `DoubleViewTubiPlayerActivity`.


Class: SelectionActivity

public class SelectionActivity extends Activity

Description

`SelectionActivity` extends Android's base `Activity` class and overrides the lifecycle method `onCreate()` to set up UI elements and define their behaviors. It does not maintain complex state or involve advanced business logic — its core function is to facilitate launching playback with predefined media selections.


Fields

Field Name

Type

Description

`VIDEO_URL`

`String`

A static final string representing the base HLS video URL used by both selections.


Methods

protected void onCreate(@Nullable Bundle savedInstanceState)

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_selection);

    Button playHls1 = findViewById(R.id.activity_selection_play_hls_1);
    playHls1.setOnClickListener(v -> {
        String subs = "http://s.adrise.tv/88703acf-66a2-4071-8231-d6cffe579f33.srt";
        String artwork = "http://images.adrise.tv/6sjdZy7rGz23YZ62_diTF26BfgE=/214x306/smart/img.adrise.tv/4b85521c-c3af-41d5-bf52-40b698c6d56d.jpg";
        String name = "longest weekend";

        Intent intent = new Intent(SelectionActivity.this, DoubleViewTubiPlayerActivity.class);
        intent.putExtra(TubiPlayerActivity.TUBI_MEDIA_KEY, MediaModel.video(name, VIDEO_URL, artwork, null));
        startActivity(intent);
    });

    Button playHls2 = findViewById(R.id.activity_selection_play_hls_2);
    playHls2.setOnClickListener(v -> {
        String artwork = "http://images.adrise.tv/q4v7JUQPPHqn8nTmYiudW6l8w_0=/214x306/smart/img.adrise.tv/1c31dfce-5338-4a09-bcb0-f68789153f33.png";
        String name = "Man on the ledge";

        Intent intent = new Intent(SelectionActivity.this, DoubleViewTubiPlayerActivity.class);
        intent.putExtra(TubiPlayerActivity.TUBI_MEDIA_KEY, MediaModel.video(name, VIDEO_URL, artwork, null));
        startActivity(intent);
    });
}

Important Implementation Details


Interaction with Other Parts of the System


Diagram: Class Structure of SelectionActivity.java

classDiagram
    class SelectionActivity {
        -VIDEO_URL: String
        +onCreate(savedInstanceState: Bundle)
    }

This diagram shows the single class `SelectionActivity`, its static string field `VIDEO_URL`, and the overridden lifecycle method `onCreate`.


Summary

`SelectionActivity.java` is a straightforward Android activity that provides a minimal but functional media selection interface. It demonstrates how to:

It acts as a bridge between user interaction and the advanced dual-player playback system, enabling easy testing and demonstration of video playback with different media assets.


Usage Notes


Appendix: Media Selection to Playback Flow

flowchart TD
    User[User taps selection button]
    MediaModel[Create MediaModel with metadata]
    Intent[Create Intent with MediaModel extra]
    PlaybackActivity[Start DoubleViewTubiPlayerActivity]
    Retrieve[Retrieve MediaModel in player]
    FSM[Initialize FSM with media]
    Playback[Start playback with dual ExoPlayers]

    User --> MediaModel --> Intent --> PlaybackActivity --> Retrieve --> FSM --> Playback

This flowchart illustrates the process from user interaction within `SelectionActivity` through to media playback initiation in the dual-player activity.


End of documentation for **SelectionActivity.java**.