MediaRouterParams.Builder


class MediaRouterParams.Builder


Builder class for MediaRouterParams.

Summary

Public constructors

Constructor for builder to create MediaRouterParams.

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Public functions

MediaRouterParams

Builds the MediaRouterParams instance.

MediaRouterParams.Builder
setDialogType(dialogType: Int)

Sets the media route controller dialog type.

MediaRouterParams.Builder

Sets whether declared MediaTransferReceiver is enabled.

MediaRouterParams.Builder

Sets whether output switcher dialogs are enabled.

MediaRouterParams.Builder

Enables media can be transferred from remote (e.g. TV) to local (e.g. phone, Bluetooth).

Public constructors

Builder

Added in 1.2.0
Builder()

Constructor for builder to create MediaRouterParams.

Builder

Added in 1.2.0
Builder(params: MediaRouterParams)

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Parameters
params: MediaRouterParams

the existing instance to copy data from.

Public functions

build

Added in 1.2.0
fun build(): MediaRouterParams

Builds the MediaRouterParams instance.

setDialogType

Added in 1.2.0
fun setDialogType(dialogType: Int): MediaRouterParams.Builder

Sets the media route controller dialog type. Default value is DIALOG_TYPE_DEFAULT.

Note that from Android R, output switcher will be used rather than the dialog type set by this method if both setOutputSwitcherEnabled output switcher} and media transfer feature are enabled.

Parameters
dialogType: Int

the dialog type

setMediaTransferReceiverEnabled

Added in 1.3.0
fun setMediaTransferReceiverEnabled(enabled: Boolean): MediaRouterParams.Builder

Sets whether declared MediaTransferReceiver is enabled. The default value is true. This method will be no-op for Android versions earlier than Android R and it stays false on devices earlier than Android R.

It can be used to disable media transfer feature when MediaTransferReceiver is declared. If set to false, media transfer feature will be disabled even when MediaTransferReceiver is declared.

It is not recommended to change this value at runtime. It could result in getting invalid routes.

setOutputSwitcherEnabled

Added in 1.2.0
fun setOutputSwitcherEnabled(enabled: Boolean): MediaRouterParams.Builder

Sets whether output switcher dialogs are enabled. This method will be no-op for Android versions earlier than Android R. Default value is false.

If set to true, and when media transfer is enabled, MediaRouteButton will show output switcher when clicked, no matter what type of dialog is set by setDialogType.

If set to false, MediaRouteButton will show the dialog type which is set by setDialogType.

setTransferToLocalEnabled

Added in 1.2.0
fun setTransferToLocalEnabled(enabled: Boolean): MediaRouterParams.Builder

Enables media can be transferred from remote (e.g. TV) to local (e.g. phone, Bluetooth). Apps that enabling this feature should handle the case in their callback properly. Default value is false.

When this is enabled, onRouteSelected will be called whenever the 'remote to local' transfer happens, regardless of the selector provided in addCallback.

Note: This method will be no-op for Android versions earlier than Android R. It has effect only when media transfer is enabled.