FinishState.java


Overview

`FinishState.java` defines the **FinishState** class, a concrete implementation of a playback state within the Finite State Machine (FSM) for media playback in the Tubi TV player system. This state represents the terminal or end state in the media player’s lifecycle, typically reached when content playback has completed.

In the FSM playback flow, `FinishState` signifies that the media session has ended, and no further playback or ad-related transitions will occur. It extends from the abstract `BaseState` class, inheriting default behaviors but providing minimal additional logic since no further state transitions or player actions are expected after reaching this state.


Class: FinishState

Declaration

public class FinishState extends BaseState

**Inheritance:**


Purpose


Methods

1. transformToState

@Override
public State transformToState(Input input, StateFactory factory)
State nextState = finishState.transformToState(Input.AD_FINISH, stateFactory);
// nextState == null => no transition, playback ended

2. performWorkAndUpdatePlayerUI

@Override
public void performWorkAndUpdatePlayerUI(@NonNull FsmPlayer fsmPlayer)

Important Implementation Details


Interaction with Other Components


Usage Example in FSM Flow

// Inside a state handling playback finish, such as MoviePlayingState
if (input == Input.MOVIE_FINISH) {
    return stateFactory.createState(FinishState.class);
}

// FSM player transitions to FinishState and calls
finishState.performWorkAndUpdatePlayerUI(fsmPlayer);

This flow ensures that once playback finishes, the FSM is moved to `FinishState`, where the player can stop or show end-of-playback UI without further transitions.


Mermaid Class Diagram

classDiagram
    class FinishState {
        +State transformToState(Input input, StateFactory factory)
        +void performWorkAndUpdatePlayerUI(FsmPlayer fsmPlayer)
    }
    FinishState --|> BaseState

Summary


Appendix: Related States and Inputs (Context)

State Name

Purpose

Typical Transition to FinishState

`MoviePlayingState`

Plays main content

On `Input.MOVIE_FINISH`

AdPlayingState

Plays ads

On `Input.AD_FINISH` (then content or finish)

VpaidState

Plays interactive VPAID ads

On [Input.VPAID_FINISH](/projects/288/68335)

Other terminal states

May also transition to `FinishState` on errors or completion

Various terminal inputs


Conclusion

`FinishState.java` is a simple yet essential component within the FSM-based media playback system representing the terminal state. Its minimal implementation is intentional to reflect the end of playback activities and prevent further FSM transitions, ensuring that the media player cleanly concludes the playback lifecycle.


*This documentation is intended for developers and maintainers working with the FSM playback module, providing clarity on the role and implementation of `FinishState` within the media player system.*