public class OCastMediaRouteHelper
This singleton provides methods to take advantage of the Android media route framework with OCast devices.
Modifier and Type | Field and Description |
---|---|
static OCastMediaRouteHelper |
INSTANCE
This singleton provides methods to take advantage of the Android media route framework with OCast devices.
|
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(EventListener listener)
Adds a listener for the OCast protocol events.
|
void |
addMediaRouterCallback(androidx.mediarouter.media.MediaRouter.Callback mediaRouterCallback)
Adds a media router callback.
|
Device |
getDeviceFromRoute(androidx.mediarouter.media.MediaRouter.RouteInfo routeInfo)
Returns the OCast device which is associated to a MediaRouter.RouteInfo.
|
java.util.List<org.ocast.sdk.core.Device> |
getDevices()
The discovered OCast devices.
|
androidx.mediarouter.media.MediaRouteSelector |
getMediaRouteSelector()
The OCast media route selector.
|
void |
initialize(android.content.Context context,
java.util.List<? extends java.lang.Class<? extends org.ocast.sdk.core.Device>> devices)
Initializes the
class OCastMediaRouteHelper singleton with the specified device classes. |
boolean |
isOCastRouteInfo(androidx.mediarouter.media.MediaRouter.RouteInfo routeInfo)
Indicates if a route info is associated with an OCast device.
|
void |
removeEventListener(EventListener listener)
Removes a listener which has been previously added with the
addEventListener(@NotNull EventListener listener) method. |
void |
removeMediaRouterCallback(androidx.mediarouter.media.MediaRouter.Callback mediaRouterCallback)
Removes a media router callback that has been previously added with the
addMediaRouterCallback(@NotNull MediaRouter.Callback mediaRouterCallback) method. |
public static OCastMediaRouteHelper INSTANCE
This singleton provides methods to take advantage of the Android media route framework with OCast devices.
@NotNull public androidx.mediarouter.media.MediaRouteSelector getMediaRouteSelector()
The OCast media route selector.
Set the routeSelector
property of the actionProvider
of your menu item with the value returned by this property
to show a dialog which displays a list of the discovered OCast devices.
@NotNull public java.util.List<org.ocast.sdk.core.Device> getDevices()
The discovered OCast devices.
public void initialize(@NotNull android.content.Context context, @NotNull java.util.List<? extends java.lang.Class<? extends org.ocast.sdk.core.Device>> devices)
Initializes the class OCastMediaRouteHelper
singleton with the specified device classes.
This method MUST be called on the main thread prior to any other method calls.
context
- The context.devices
- The classes of devices that will be searched during the discovery process.class OCastMediaRouteHelper
public void addMediaRouterCallback(@NotNull androidx.mediarouter.media.MediaRouter.Callback mediaRouterCallback)
Adds a media router callback.
mediaRouterCallback
- The callback to add.public void removeMediaRouterCallback(@NotNull androidx.mediarouter.media.MediaRouter.Callback mediaRouterCallback)
Removes a media router callback that has been previously added with the addMediaRouterCallback(@NotNull MediaRouter.Callback mediaRouterCallback)
method.
mediaRouterCallback
- The callback to remove.@Nullable public Device getDeviceFromRoute(@Nullable androidx.mediarouter.media.MediaRouter.RouteInfo routeInfo)
Returns the OCast device which is associated to a MediaRouter.RouteInfo.
routeInfo
- The route info.public boolean isOCastRouteInfo(@Nullable androidx.mediarouter.media.MediaRouter.RouteInfo routeInfo)
Indicates if a route info is associated with an OCast device.
public void addEventListener(@NotNull EventListener listener)
Adds a listener for the OCast protocol events.
listener
- The listener to add.public void removeEventListener(@NotNull EventListener listener)
Removes a listener which has been previously added with the addEventListener(@NotNull EventListener listener)
method.
listener
- The listener to remove.