SceneType

更新时间:
复制 MD 格式

SceneType is an abstraction in AliPlayerKit for defining playback scenarios. By specifying a SceneType, the player automatically adapts its UI behavior, gesture controls, and slot visibility.

Scene overview

Scene

Description

Use cases

Differences from VOD

VOD

The default scene, which supports all control features and requires no explicit configuration.

Standard VOD, online courses, and media libraries.

LIVE

A live stream has no fixed duration, so the player automatically disables timeline operations.

Live events, sports, and e-commerce live streams.

Disables progress scrubbing, fast-forward, and playback speed controls; hides the coverImage and seekThumbnail slots.

VIDEO_LIST

Disables vertical gestures to prevent conflicts with list scrolling.

Feeds and short video lists.

Disables vertical gestures for volume and brightness; other behaviors are the same as for VOD.

RESTRICTED

Prevents users from skipping forward to ensure they watch the content in sequence.

Exam proctoring and mandatory training courses.

Disables progress scrubbing, fast-forward, and playback speed controls; hides the coverImage and seekThumbnail slots.

MINIMAL

Provides a clean player surface. The developer must implement all controls.

Background playback and fully customized UIs.

Hides all control components and disables all gestures; only the playerSurface, playState, and overlays slots are visible.

Configuration

Specify the SceneType by using the sceneType() method of AliPlayerModel.Builder. Since VOD is the default scene, you only need to specify a SceneType for other scenarios.

LIVE scene:

// Build the player model and set the scene type to LIVE.
AliPlayerModel playerModel = new AliPlayerModel.Builder()
    .videoSource(videoSource)
    .videoTitle("Live Stream")
    .sceneType(SceneType.LIVE)
    .build();

// Bind the model to the player view.
controller.configure(playerModel);
playerView.attach(controller);

SceneType and slot interaction

Slot visibility

The Slot System automatically controls component visibility based on the SceneType:

Slot

VOD

LIVE

VIDEO_LIST

RESTRICTED

MINIMAL

playerSurface

playState

overlays

coverImage

seekThumbnail

playControl

topBar

bottomBar

settingMenu

gestureControl

Gesture behavior differences

Gesture

VOD

LIVE

VIDEO_LIST

RESTRICTED

MINIMAL

Single tap (show/hide control bar)

Double-tap (play/pause)

Long-press (2x playback speed)

Horizontal drag (seek)

Left vertical drag (brightness)

Right vertical drag (volume)

Best practices

  1. The scene type is set upon creation: The SceneType is specified when an AliPlayerModel is created and cannot be dynamically switched during playback. To switch scenes, you must create a new AliPlayerModel and rebind it.

  2. Use the list scene for scrollable containers: When embedding the player in a scrollable container like a RecyclerView, always use the VIDEO_LIST scene to prevent conflicts with vertical scroll gestures.

  3. Implement controls for the MINIMAL scene: When you select the MINIMAL scene, you must implement all playback controls by using custom slots.

  4. Advanced customization: If a SceneType's preset behavior does not meet your needs, use the Slot System to further customize component visibility and layout. For more information, see Slot System.

FAQ

Differences between VOD and VIDEO_LIST

The main difference is how they handle vertical gestures. VIDEO_LIST disables vertical gestures for adjusting volume and brightness to avoid conflicting with the parent container's scrolling gestures. Other features are identical to VOD.

Custom controls in the MINIMAL scene

You can overlay a custom control UI by using custom slots:

AliPlayerModel playerModel = new AliPlayerModel.Builder()
    .videoSource(videoSource)
    .sceneType(SceneType.MINIMAL)
    .build();

AliPlayerController controller = new AliPlayerController(this);
controller.configure(playerModel);

SlotManager slotManager = playerView.getSlotManager();
slotManager.register(SlotType.BOTTOM_BAR, parent -> new MyCustomControlSlot(parent.getContext()));
playerView.attach(controller);