loadVideoSource

public void loadVideoSource(String uri, Bundle config)

Loads a video source for playback.

Initiates playback of a media file specified by the URI, with optional configuration, rendering to the SurfaceView provided at construction.

Example usage:

SurfaceView surfaceView = findViewById(R.id.surface_view);
SandboxedPlayer player = new SandboxedPlayer(context, surfaceView);
Bundle config = new Bundle();
config.putBoolean("loop_on_end", true);
player.loadVideoSource("http://example.com/video.mp4", config);

Parameters

uri

The media URI (e.g., "http://example.com/video.mp4").

config

Optional configuration, or null. Supported keys include:

  • "mute_when_open" (boolean, optional): Controls audio muting behavior during channel zapping. If true, audio is muted until the first frame is rendered; if false, audio plays immediately. Default: true. Example: config.putBoolean("mute_when_open", false)
  • "encryption_type" (String, optional): Specifies the encryption type for DRM-protected content. Valid values are:
    • "com.widevine.alpha": Widevine DRM.
    • "com.microsoft.playready": PlayReady DRM.
    Default: No encryption if not specified.
  • "encrypting_server" (String, optional): URL of the encrypting server for DRM license requests. Required if encryption_type is set to a DRM type.
  • "encrypting_request_header" (Object, optional): Additional headers for DRM license requests, typically a Map<String, String> or similar object. Format depends on the player implementation.
  • "drm_session_type" (String, optional): Specifies the DRM session type. Set to "persistent" to persist the license and keys (requires server support, e.g., Widevine). Default: Non-persistent session if not specified.
  • "loop_on_end" (boolean, optional): Controls whether the video replays upon reaching the end. If true, the video loops; if false, it stops. Default: false.