我遇到了一个问题,当两个设备连接到同一个投射会话并且从设备1调用BaseCastManager.setDeviceMute()
时,设备2没有收到MediaCallback.onRouteVolumeChanged()
这样做的正确方法是什么?可能有不同的回调吗?
这是最终被调用的内容。
/**
* Mutes or un-mutes the device volume.
*
* @throws CastException
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public final void setDeviceMute(boolean mute) throws CastException,
TransientNetworkDisconnectionException, NoConnectionException {
checkConnectivity();
try {
Cast.CastApi.setMute(mApiClient, mute);
} catch (IOException e) {
throw new CastException("setDeviceMute", e);
} catch (IllegalStateException e) {
throw new NoConnectionException("setDeviceMute()", e);
}
}
这是我的听众:
private class MediaCallBack extends android.support.v7.media.MediaRouter.Callback {
@Override
public void onRouteVolumeChanged(MediaRouter router,
RouteInfo route) {
super.onRouteVolumeChanged(router, route);
onVolumeChanged(route.getVolume());
}
}
答案 0 :(得分:1)
您需要收听onVolumeChanged
的回调Cast.Listener
:
public void onVolumeChanged()
当设备的音量或静音状态发生变化时调用。
答案 1 :(得分:1)
由于您使用的是Cast Companion Library,您可以通过扩展[2016-05-05 20:47:03] event.DEBUG: Notified event "console.command" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure". [] []
[2016-05-05 20:47:03] event.DEBUG: Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand". [] []
[2016-05-05 20:47:03] event.DEBUG: Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand". [] []
[2016-05-05 20:47:03] php.DEBUG: fsockopen(): unable to connect to 127.0.0.1:8000 (Connection refused) {"type":2,"file":"/home/me/projects/myproject/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php","line":59,"level":28928} []
[2016-05-05 20:47:03] event.DEBUG: Notified event "console.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate". [] []
[2016-05-05 20:47:03] event.DEBUG: Notified event "console.terminate" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onTerminate". [] []
[2016-05-05 20:47:03] event.DEBUG: Notified event "console.terminate" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onTerminate". [] []
来使用回调VideoCastConsumer#onVolumeChanged(double value, boolean isMute)
,覆盖该方法并将其注册到VideoCastConsumerImpl
(并在不再需要时取消注册) ):
VideoCastManager