com.google.android.gms.cast.framework.media.NotificationOptions Java Examples

The following examples show how to use com.google.android.gms.cast.framework.media.NotificationOptions. 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: CastOptionsProvider.java    From vinyl-cast with MIT License 7 votes vote down vote up
@Override
public CastOptions getCastOptions(Context appContext) {

    List<String> buttonActions = new ArrayList<>();
    buttonActions.add(MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK);
    buttonActions.add(MediaIntentReceiver.ACTION_STOP_CASTING);
    // Showing "play/pause" and "stop casting" in the compat view of the notification.
    int[] compatButtonActionsIndices = new int[]{ 0, 1 };
    // Builds a notification with the above actions.
    // Tapping on the notification opens an Activity with class VideoBrowserActivity.
    NotificationOptions notificationOptions = new NotificationOptions.Builder()
            .setActions(buttonActions, compatButtonActionsIndices)
            .setTargetActivityClassName(MainActivity.class.getName())
            .build();

    CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
            .setNotificationOptions(notificationOptions)
            .build();

    CastOptions castOptions = new CastOptions.Builder()
            .setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
            .setCastMediaOptions(mediaOptions)
            .build();
    return castOptions;
}
 
Example #2
Source File: CastOptionsProvider.java    From Casty with MIT License 7 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    CastOptions customCastOptions = Casty.customCastOptions;
    if(customCastOptions == null) {
        List<String> buttonActions = createButtonActions();
        int[] compatButtonAction = { 1, 3 };

        NotificationOptions notificationOptions = new NotificationOptions.Builder()
                .setActions(buttonActions, compatButtonAction)
                .setTargetActivityClassName(ExpandedControlsActivity.class.getName())
                .build();

        CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
                .setNotificationOptions(notificationOptions)
                .setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
                .build();

        return new CastOptions.Builder()
                .setReceiverApplicationId(Casty.receiverId)
                .setCastMediaOptions(mediaOptions)
                .build();
    } else {
        return customCastOptions;
    }
}
 
Example #3
Source File: CastOptionsProvider.java    From CastVideos-android with Apache License 2.0 6 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    NotificationOptions notificationOptions = new NotificationOptions.Builder()
            .setActions(Arrays.asList(MediaIntentReceiver.ACTION_SKIP_NEXT,
                    MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK,
                    MediaIntentReceiver.ACTION_STOP_CASTING), new int[]{1, 2})
            .setTargetActivityClassName(ExpandedControlsActivity.class.getName())
            .build();
    CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
            .setImagePicker(new ImagePickerImpl())
            .setNotificationOptions(notificationOptions)
            .setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
            .build();
    return new CastOptions.Builder()
            .setReceiverApplicationId(context.getString(R.string.app_id))
            .setCastMediaOptions(mediaOptions)
            .build();
}
 
Example #4
Source File: GoogleCastOptionsProvider.java    From react-native-google-cast with MIT License 5 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
  NotificationOptions notificationOptions =
      new NotificationOptions.Builder()
          .setActions(
              Arrays.asList(MediaIntentReceiver.ACTION_SKIP_NEXT,
                            MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK,
                            MediaIntentReceiver.ACTION_STOP_CASTING),
              new int[] {1, 2})
          .setTargetActivityClassName(
              GoogleCastExpandedControlsActivity.class.getName())
          .build();

  CastMediaOptions mediaOptions =
      new CastMediaOptions.Builder()
          .setImagePicker(new ImagePickerImpl())
          .setNotificationOptions(notificationOptions)
          .setExpandedControllerActivityClassName(
              GoogleCastExpandedControlsActivity.class.getName())
          .build();

  return new CastOptions.Builder()
      .setReceiverApplicationId(
          CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
      .setCastMediaOptions(mediaOptions)
      .build();
}
 
Example #5
Source File: CastOptionsProvider.java    From cast-videos-android with Apache License 2.0 5 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    NotificationOptions notificationOptions = new NotificationOptions.Builder()
            .setTargetActivityClassName(ExpandedControlsActivity.class.getName())
            .build();
    CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
            .setNotificationOptions(notificationOptions)
            .setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
            .build();

    return new CastOptions.Builder()
            .setReceiverApplicationId(context.getString(R.string.app_id))
            .setCastMediaOptions(mediaOptions)
            .build();
}
 
Example #6
Source File: CastOptionsProvider.java    From SkyTube with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
	List<String> buttonActions = new ArrayList<>();
	buttonActions.add(MediaIntentReceiver.ACTION_REWIND);
	buttonActions.add(MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK);
	buttonActions.add(MediaIntentReceiver.ACTION_FORWARD);
	buttonActions.add(MediaIntentReceiver.ACTION_STOP_CASTING);
	// Showing "play/pause" and "stop casting" in the compat view of the notification.
	int[] compatButtonActionsIndicies = new int[]{ 1, 3 };
	// Builds a notification with the above actions. Each tap on the "rewind" and
	// "forward" buttons skips 30 seconds.
	// Tapping on the notification opens an Activity with class MainActivity.
	NotificationOptions notificationOptions = new NotificationOptions.Builder()
					.setActions(buttonActions, compatButtonActionsIndicies)
					.setSkipStepMs(30 * DateUtils.SECOND_IN_MILLIS)
					.setTargetActivityClassName(NotificationClickActivity.class.getName())
					.build();

	CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
					.setNotificationOptions(notificationOptions)
					.build();



	return new CastOptions.Builder()
					.setReceiverApplicationId(BuildConfig.CHROMECAST_APP_ID)
					.setCastMediaOptions(mediaOptions)
					.build();
}
 
Example #7
Source File: CastOptionsProvider.java    From Loop with Apache License 2.0 5 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    NotificationOptions notificationOptions = new NotificationOptions.Builder()
            .setTargetActivityClassName(LauncherActivity.class.getName())
            .build();
    CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
            .setNotificationOptions(notificationOptions)
            .build();

    return new CastOptions.Builder()
            .setReceiverApplicationId(context.getString(R.string.cast_app_id))
            .setCastMediaOptions(mediaOptions)
            .build();
}
 
Example #8
Source File: CastOptionsProvider.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    final NotificationOptions notificationOptions = new NotificationOptions.Builder()
            .setTargetActivityClassName(ExpandedControlsActivity.class.getName())
            .build();
    final CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
            .setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
            .setImagePicker(new ImagePickerImpl())
            .setNotificationOptions(notificationOptions)
            .build();
    return new CastOptions.Builder()
            .setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
            .setCastMediaOptions(mediaOptions)
            .build();
}
 
Example #9
Source File: CastOptionsProvider.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    List<String> buttonActions = new ArrayList<>();

    buttonActions.add(MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK);
    buttonActions.add(MediaIntentReceiver.ACTION_STOP_CASTING);

    int[] compatButtonActionsIndicies = new int[]{ 0, 1 };

    NotificationOptions notificationOptions = new NotificationOptions.Builder()
            .setActions(buttonActions, compatButtonActionsIndicies)
            .setTargetActivityClassName(ExpandedControlsActivity.class.getName())
            .build();

    CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
            .setNotificationOptions(notificationOptions)
            .setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
            .build();

    CastOptions castOptions = new CastOptions.Builder()
            .setResumeSavedSession(true)
            .setEnableReconnectionService(true)
            .setReceiverApplicationId(context.getString(R.string.cast_app_id))
            .setCastMediaOptions(mediaOptions)
            .build();

    return castOptions;
}