use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by DirtyUnicorns.
the class CastControllerImpl method updateRemoteDisplays.
private void updateRemoteDisplays() {
synchronized (mRoutes) {
mRoutes.clear();
final int n = mMediaRouter.getRouteCount();
for (int i = 0; i < n; i++) {
final RouteInfo route = mMediaRouter.getRouteAt(i);
if (!route.isEnabled())
continue;
if (!route.matchesTypes(ROUTE_TYPE_REMOTE_DISPLAY))
continue;
ensureTagExists(route);
mRoutes.put(route.getTag().toString(), route);
}
final RouteInfo selected = mMediaRouter.getSelectedRoute(ROUTE_TYPE_REMOTE_DISPLAY);
if (selected != null && !selected.isDefault()) {
ensureTagExists(selected);
mRoutes.put(selected.getTag().toString(), selected);
}
}
fireOnCastDevicesChanged();
}
use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by DirtyUnicorns.
the class CastControllerImpl method getCastDevices.
@Override
public Set<CastDevice> getCastDevices() {
final ArraySet<CastDevice> devices = new ArraySet<CastDevice>();
synchronized (mProjectionLock) {
if (mProjection != null) {
final CastDevice device = new CastDevice();
device.id = mProjection.getPackageName();
device.name = getAppName(mProjection.getPackageName());
device.description = mContext.getString(R.string.quick_settings_casting);
device.state = CastDevice.STATE_CONNECTED;
device.tag = mProjection;
devices.add(device);
return devices;
}
}
synchronized (mRoutes) {
for (RouteInfo route : mRoutes.values()) {
final CastDevice device = new CastDevice();
device.id = route.getTag().toString();
final CharSequence name = route.getName(mContext);
device.name = name != null ? name.toString() : null;
final CharSequence description = route.getDescription();
device.description = description != null ? description.toString() : null;
device.state = route.isConnecting() ? CastDevice.STATE_CONNECTING : route.isSelected() ? CastDevice.STATE_CONNECTED : CastDevice.STATE_DISCONNECTED;
device.tag = route;
devices.add(device);
}
}
return devices;
}
use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by ParanoidAndroid.
the class MediaRouteChooserDialogFragment method updateVolume.
void updateVolume() {
if (mRouter == null)
return;
final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
mVolumeIcon.setImageResource(selectedRoute == null || selectedRoute.getPlaybackType() == RouteInfo.PLAYBACK_TYPE_LOCAL ? R.drawable.ic_audio_vol : R.drawable.ic_media_route_on_holo_dark);
mIgnoreSliderVolumeChanges = true;
if (selectedRoute == null || selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_FIXED) {
// Disable the slider and show it at max volume.
mVolumeSlider.setMax(1);
mVolumeSlider.setProgress(1);
mVolumeSlider.setEnabled(false);
} else {
mVolumeSlider.setEnabled(true);
mVolumeSlider.setMax(selectedRoute.getVolumeMax());
mVolumeSlider.setProgress(selectedRoute.getVolume());
}
mIgnoreSliderVolumeChanges = false;
}
use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by ParanoidAndroid.
the class MediaRouteChooserDialogFragment method changeVolume.
void changeVolume(int newValue) {
if (mIgnoreSliderVolumeChanges)
return;
final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
if (selectedRoute != null && selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) {
final int maxVolume = selectedRoute.getVolumeMax();
newValue = Math.max(0, Math.min(newValue, maxVolume));
selectedRoute.requestSetVolume(newValue);
}
}
use of android.media.MediaRouter.RouteInfo in project platform_frameworks_base by android.
the class CastControllerImpl method getCastDevices.
@Override
public Set<CastDevice> getCastDevices() {
final ArraySet<CastDevice> devices = new ArraySet<CastDevice>();
synchronized (mProjectionLock) {
if (mProjection != null) {
final CastDevice device = new CastDevice();
device.id = mProjection.getPackageName();
device.name = getAppName(mProjection.getPackageName());
device.description = mContext.getString(R.string.quick_settings_casting);
device.state = CastDevice.STATE_CONNECTED;
device.tag = mProjection;
devices.add(device);
return devices;
}
}
synchronized (mRoutes) {
for (RouteInfo route : mRoutes.values()) {
final CastDevice device = new CastDevice();
device.id = route.getTag().toString();
final CharSequence name = route.getName(mContext);
device.name = name != null ? name.toString() : null;
final CharSequence description = route.getDescription();
device.description = description != null ? description.toString() : null;
device.state = route.isConnecting() ? CastDevice.STATE_CONNECTING : route.isSelected() ? CastDevice.STATE_CONNECTED : CastDevice.STATE_DISCONNECTED;
device.tag = route;
devices.add(device);
}
}
return devices;
}
Aggregations