@UnstableApi
class CastParams


Contains Cast configuration options.

Options contained in this class can be passed to initialize in order to set up the Cast configuration as part of initialization, or to change the Cast configuration after initialization has completed.

Options set in this class take precedence over Cast options, such as DefaultCastOptionsProvider, or Manifest-provided Cast options. However, options not set in this class (modeled using null) fall back to Manifest-provided options, if available, or DefaultCastOptionsProvider options otherwise.

See also
initialize

Summary

Nested types

Builder for CastParams.

Constants

const CastParams!

Public properties

String?

Returns the Cast receiver application ID, or null if not set.

Boolean?

Returns whether to enable the remote to local feature, or null if not set.

Boolean?

Returns whether to show system output switcher when clicking on the cast button, or null if not set.

Boolean?

Returns whether the system output switcher is enabled or null if not set.

Constants

DEFAULT

const val DEFAULT: CastParams!

Public properties

receiverApplicationId

val receiverApplicationId: String?

Returns the Cast receiver application ID, or null if not set.

If not set, the receiver application ID defaults to the one set in the Manifest-provided Cast options if provided, or the one set in DefaultCastOptionsProvider otherwise.

remoteToLocalEnabled

val remoteToLocalEnabled: Boolean?

Returns whether to enable the remote to local feature, or null if not set.

If not set, the "remote to local enabled" config defaults to the one set in the Manifest-provided Cast options if provided, or the one set in DefaultCastOptionsProvider otherwise.

showSystemOutputSwitcherOnCastButtonClick

val showSystemOutputSwitcherOnCastButtonClick: Boolean?

Returns whether to show system output switcher when clicking on the cast button, or null if not set.

Note that launching the system output switcher on cast button click requires the system output switcher integration (getSystemOutputSwitcherEnabled) to be enabled. If setSystemOutputSwitcherEnabled is set to false, it overrides this setting and the cast button will always launch the in-app device picker dialog even if this option is set to true.

Calling setShowSystemOutputSwitcherOnCastButtonClick with true implicitly enables the system output switcher integration (getSystemOutputSwitcherEnabled) if setSystemOutputSwitcherEnabled is not explicitly called.

This configuration is ignored on devices running API level 36 or older, and the cast button always launches the in-app device picker. On devices running API level 37 or newer, the value set by the application is respected, but the default value (the value used when the application doesn't call setShowSystemOutputSwitcherOnCastButtonClick) depends on the target SDK, and on the way the app configures Cast options:

  • For applications using Manifest-provided Cast options (and not calling initialize), the default value is false.
  • For applications using initialize whose target SDK is 36 or older, the default value is false.
  • For applications using initialize whose target SDK is 37 or newer, the default value is true.

systemOutputSwitcherEnabled

val systemOutputSwitcherEnabled: Boolean?

Returns whether the system output switcher is enabled or null if not set.

When enabled, Cast routes are exposed to the Android system output switcher (allowing users to transfer playback between the local device and Cast devices from the system media notification, volume controls, or in-app Cast button) without requiring MediaTransferReceiver to be declared in the app's AndroidManifest.xml.

When set to false, Cast routes are not exposed to the system output switcher. Setting this option to false also overrides setShowSystemOutputSwitcherOnCastButtonClick if it is set to true, causing the in-app Cast button to launch the in-app media route chooser dialog instead.

This configuration is ignored on devices running API level 36 or older. On devices running API level 37 or newer, the value set by the application is respected, and the default value when not explicitly set depends on the target SDK and Cast options configuration:

  • For applications using Manifest-provided Cast options (and not calling initialize), the default value is determined by whether MediaTransferReceiver is declared in the manifest.
  • For applications using initialize whose target SDK is 36 or older, the default value is false (unless setShowSystemOutputSwitcherOnCastButtonClick is explicitly set to true).
  • For applications using initialize whose target SDK is 37 or newer, the default value is true.