其他分享
首页 > 其他分享> > 从Android控制第三方Cast会话?

从Android控制第三方Cast会话?

作者:互联网

我想观察并控制由另一个应用启动的Chromecast会话.

但是,在使用MediaRouter进行连接时,我无法在不中断的情况下加入正在进行的会话.一旦我选择了一条路线,我的应用就会取代之前的路线.

如何使用Android SDK监控Chromecast会话(并且能够播放,暂停,查看进度等),而无需替换当前正在播放的接收器应用?

解决方法:

第一选择:

你可以使用RemotePlaybackClient

Controlling a remote playback route

When you select a remote playback route your app acts as a remote
control. The device at the other end of the route handles all content
data retrieval, decoding, and playback functions. The controls in your
app’s UI communicate with the receiver device using a
RemotePlaybackClient object.

Javadoc

RemotePlaybackClient

A helper class for playing media on remote routes using the remote
playback protocol defined by MediaControlIntent.

The client maintains session state and offers a simplified interface
for issuing remote playback media control intents to a single route.

您可以使用RemotePlaybackClient(Context context,MediaRouter.RouteInfo route)创建它

您可以通过调用route.supportsControlCategory来检查MediaRouter.Route是否支持远程请求

第二种选择:

如果您的应用不支持此功能,您可以尝试通过CastSession管理.这样,您的应用将通过chromeecast与其他应用进行通信.随着CastSession.getRemoteMediaClient()你得到RemoteMediaClient.

标签:android,chromecast
来源: https://codeday.me/bug/20190701/1345816.html