5

When registering the MinimalMediaRouteProvider/MediaRouteButton from Androids Chromecast SDK, we get a standard dialog for connecting to existing Cromecast Devices. Once connected to the device, same dialog also provides a way to set the volume using a draggable seek bar. I am having trouble synchronizing the position of this volume seek bar with the actual volume that is already set in the Chromecast device.

As part of registering the MinimalMediaRouteProvider we provide a com.google.cast.MediaRouteAdapter implementation. The onSetVolume(volume) of this interface is called when the user drags the volume seekBar above. This gives us a god way to update the volume level of the connected chromecast channel by using messageStream.setVolume(volume).

The problem is that once we update the volume, there is no way to tell back the MinimalMediaRouteProvider UI that the volume has changed so it can position itself accordingly - currently it always shows the volume as 0.

What is the proper way to notify the MinimalMediaRouteProvider about the current volume level so it can update its volume UI?

Looking at the MediaRoute sample included with support library 7, there seem to be a way to create MediaRouteDescriptor, update the volume there and thus communicate this back to the MediaRouteProvider, but but it is not very clear how to do this in the content of Chromecast/MinimalMediaRouteProvider.

4

2 回答 2

1

您可以调用MediaRouteStateListener.onVolumeChanged()以更新音量搜索栏。

我在这里有更详细的答案: https ://stackoverflow.com/a/18867128/1334870

于 2013-09-18T08:22:04.993 回答
0

要立即从 VideoCastManager 获取音量:

mVolume = (int) (mCastManager.getVolume() * 100) // cast volume is double

要在接收器中接收基于系统的音量变化(即屏幕上的音量滑块弹出,其他连接的设备改变音量),您需要在控制器活动中添加演员消费者:

private VideoCastConsumerImpl mCastConsumer = new VideoCastConsumerImpl() {

    public void onVolumeChanged(double volume, boolean isMute)
    {
        mVolumeSeekBar.setProgress((int) (volume *100));
    }
};

更多细节:

Android Sender 应用程序开发(2014 年 8 月)

于 2014-10-24T18:25:33.847 回答