android.support.v7.media.MediaRouteProviderDescriptor Java Examples

The following examples show how to use android.support.v7.media.MediaRouteProviderDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JukeboxRouteProvider.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
private void broadcastDescriptor() {
	// Create intents
	IntentFilter routeIntentFilter = new IntentFilter();
	routeIntentFilter.addCategory(CATEGORY_JUKEBOX_ROUTE);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_START_SESSION);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_GET_SESSION_STATUS);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_END_SESSION);

	// Create route descriptor
	MediaRouteDescriptor.Builder routeBuilder = new MediaRouteDescriptor.Builder("Jukebox Route", "Subsonic Jukebox");
	routeBuilder.addControlFilter(routeIntentFilter)
			.setPlaybackStream(AudioManager.STREAM_MUSIC)
			.setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
			.setDescription("Subsonic Jukebox")
			.setVolume(controller == null ? 5 : (int) (controller.getVolume() * 10))
			.setVolumeMax(MAX_VOLUME)
			.setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE);

	// Create descriptor
	MediaRouteProviderDescriptor.Builder providerBuilder = new MediaRouteProviderDescriptor.Builder();
	providerBuilder.addRoute(routeBuilder.build());
	setDescriptor(providerBuilder.build());
}
 
Example #2
Source File: DLNARouteProvider.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
private void broadcastDescriptors() {
	// Create intents
	IntentFilter routeIntentFilter = new IntentFilter();
	routeIntentFilter.addCategory(CATEGORY_DLNA);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_START_SESSION);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_GET_SESSION_STATUS);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_END_SESSION);

	// Create descriptor
	MediaRouteProviderDescriptor.Builder providerBuilder = new MediaRouteProviderDescriptor.Builder();

	// Create route descriptor
	for(Map.Entry<String, DLNADevice> deviceEntry: devices.entrySet()) {
		DLNADevice device = deviceEntry.getValue();

		int volume;
		if(device.volumeMax <= 0) {
			volume = 5;
		} else {
			int increments = (int) Math.ceil(device.volumeMax / 10.0);
			volume = controller == null ? device.volume : (int) controller.getVolume();
			volume = volume / increments;
		}

		MediaRouteDescriptor.Builder routeBuilder = new MediaRouteDescriptor.Builder(device.id, device.name);
		routeBuilder.addControlFilter(routeIntentFilter)
				.setPlaybackStream(AudioManager.STREAM_MUSIC)
				.setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
				.setDescription(device.description)
				.setVolume(volume)
				.setVolumeMax(10)
				.setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE);
		providerBuilder.addRoute(routeBuilder.build());
	}

	setDescriptor(providerBuilder.build());
}
 
Example #3
Source File: CastMediaRouteProvider.java    From android_packages_apps_GmsCore with Apache License 2.0 5 votes vote down vote up
private void publishRoutes() {
    MediaRouteProviderDescriptor.Builder builder = new MediaRouteProviderDescriptor.Builder();
    for (CastDevice castDevice : this.castDevices.values()) {
        ArrayList<IntentFilter> controlFilters = new ArrayList<IntentFilter>(BASE_CONTROL_FILTERS);
        // Include any app-specific control filters that have been requested.
        // TODO: Do we need to check with the device?
        for (String category : this.customCategories) {
            IntentFilter filter = new IntentFilter();
            filter.addCategory(category);
            controlFilters.add(filter);
        }

        Bundle extras = new Bundle();
        castDevice.putInBundle(extras);
        MediaRouteDescriptor route = new MediaRouteDescriptor.Builder(
            castDevice.getDeviceId(),
            castDevice.getFriendlyName())
            .setDescription(castDevice.getModelName())
            .addControlFilters(controlFilters)
            .setDeviceType(MediaRouter.RouteInfo.DEVICE_TYPE_TV)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED)
            .setVolumeMax(20)
            .setVolume(0)
            .setEnabled(true)
            .setExtras(extras)
            .setConnectionState(MediaRouter.RouteInfo.CONNECTION_STATE_DISCONNECTED)
            .build();
        builder.addRoute(route);
    }
    this.setDescriptor(builder.build());
}
 
Example #4
Source File: SampleMediaRouteProvider.java    From android-MediaRouter with Apache License 2.0 4 votes vote down vote up
private void publishRoutes() {
    Resources r = getContext().getResources();

    MediaRouteDescriptor routeDescriptor1 = new MediaRouteDescriptor.Builder(
            FIXED_VOLUME_ROUTE_ID,
            r.getString(R.string.fixed_volume_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_BASIC)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED)
            .setVolume(VOLUME_MAX)
            .build();

    MediaRouteDescriptor routeDescriptor2 = new MediaRouteDescriptor.Builder(
            VARIABLE_VOLUME_BASIC_ROUTE_ID,
            r.getString(R.string.variable_volume_basic_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_BASIC)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
            .setVolumeMax(VOLUME_MAX)
            .setVolume(mVolume)
            .build();

    MediaRouteDescriptor routeDescriptor3 = new MediaRouteDescriptor.Builder(
            VARIABLE_VOLUME_QUEUING_ROUTE_ID,
            r.getString(R.string.variable_volume_queuing_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_QUEUING)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
            .setVolumeMax(VOLUME_MAX)
            .setVolume(mVolume)
            .build();

    MediaRouteDescriptor routeDescriptor4 = new MediaRouteDescriptor.Builder(
            VARIABLE_VOLUME_SESSION_ROUTE_ID,
            r.getString(R.string.variable_volume_session_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_SESSION)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
            .setVolumeMax(VOLUME_MAX)
            .setVolume(mVolume)
            .build();

    MediaRouteProviderDescriptor providerDescriptor =
            new MediaRouteProviderDescriptor.Builder()
            .addRoute(routeDescriptor1)
            .addRoute(routeDescriptor2)
            .addRoute(routeDescriptor3)
            .addRoute(routeDescriptor4)
            .build();
    setDescriptor(providerDescriptor);
}
 
Example #5
Source File: SampleMediaRouteProvider.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
private void publishRoutes() {
    Resources r = getContext().getResources();

    MediaRouteDescriptor routeDescriptor1 = new MediaRouteDescriptor.Builder(
            FIXED_VOLUME_ROUTE_ID,
            r.getString(R.string.fixed_volume_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_BASIC)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED)
            .setVolume(VOLUME_MAX)
            .build();

    MediaRouteDescriptor routeDescriptor2 = new MediaRouteDescriptor.Builder(
            VARIABLE_VOLUME_BASIC_ROUTE_ID,
            r.getString(R.string.variable_volume_basic_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_BASIC)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
            .setVolumeMax(VOLUME_MAX)
            .setVolume(mVolume)
            .build();

    MediaRouteDescriptor routeDescriptor3 = new MediaRouteDescriptor.Builder(
            VARIABLE_VOLUME_QUEUING_ROUTE_ID,
            r.getString(R.string.variable_volume_queuing_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_QUEUING)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
            .setVolumeMax(VOLUME_MAX)
            .setVolume(mVolume)
            .build();

    MediaRouteDescriptor routeDescriptor4 = new MediaRouteDescriptor.Builder(
            VARIABLE_VOLUME_SESSION_ROUTE_ID,
            r.getString(R.string.variable_volume_session_route_name))
            .setDescription(r.getString(R.string.sample_route_description))
            .addControlFilters(CONTROL_FILTERS_SESSION)
            .setPlaybackStream(AudioManager.STREAM_MUSIC)
            .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
            .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
            .setVolumeMax(VOLUME_MAX)
            .setVolume(mVolume)
            .build();

    MediaRouteProviderDescriptor providerDescriptor =
            new MediaRouteProviderDescriptor.Builder()
            .addRoute(routeDescriptor1)
            .addRoute(routeDescriptor2)
            .addRoute(routeDescriptor3)
            .addRoute(routeDescriptor4)
            .build();
    setDescriptor(providerDescriptor);
}