com.google.android.gms.cast.framework.CastOptions Java Examples

The following examples show how to use com.google.android.gms.cast.framework.CastOptions. 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 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 #2
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 #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: CastContextImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 6 votes vote down vote up
public CastContextImpl(IObjectWrapper context, CastOptions options, IMediaRouter router, Map<String, IBinder> sessionProviders) throws RemoteException {
    this.context = (Context) ObjectWrapper.unwrap(context);
    this.options = options;
    this.router = router;
    for (Map.Entry<String, IBinder> entry : sessionProviders.entrySet()) {
        this.sessionProviders.put(entry.getKey(), ISessionProvider.Stub.asInterface(entry.getValue()));
    }

    String receiverApplicationId = options.getReceiverApplicationId();
    String defaultCategory = CastMediaControlIntent.categoryForCast(receiverApplicationId);

    this.defaultSessionProvider = this.sessionProviders.get(defaultCategory);

    // TODO: This should incorporate passed options
    this.mergedSelector = new MediaRouteSelector.Builder()
        .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
        .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
        .addControlCategory(defaultCategory)
        .build();
}
 
Example #5
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;
}
 
Example #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: CastSessionImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 5 votes vote down vote up
public CastSessionImpl(CastOptions options, IObjectWrapper session, ICastConnectionController controller) throws RemoteException {
    this.options = options;
    this.session = (SessionImpl) ObjectWrapper.unwrap(session);
    this.controller = controller;

    this.session.setCastSession(this);
}
 
Example #12
Source File: CastOptionsProvider.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    return new CastOptions.Builder()
            .setReceiverApplicationId(context.getString(R.string.application_id))
            .build();
}
 
Example #13
Source File: CastOptionsProvider.java    From googleads-ima-android with Apache License 2.0 4 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
  return new CastOptions.Builder().setReceiverApplicationId(CastApplication.APP_ID).build();
}
 
Example #14
Source File: CastContextImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 4 votes vote down vote up
public CastOptions getOptions() {
    return this.options;
}
 
Example #15
Source File: CastDynamiteModuleImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 4 votes vote down vote up
@Override
public ICastSession newCastSessionImpl(CastOptions options, IObjectWrapper session, ICastConnectionController controller) throws RemoteException {
    return new CastSessionImpl(options, session, controller);
}
 
Example #16
Source File: CastDynamiteModuleImpl.java    From android_packages_apps_GmsCore with Apache License 2.0 4 votes vote down vote up
@Override
public ICastContext newCastContextImpl(IObjectWrapper context, CastOptions options, IMediaRouter router, Map sessionProviders) throws RemoteException {
    return new CastContextImpl(context, options, router, sessionProviders);
}
 
Example #17
Source File: CastOptionsProvider.java    From klingar with Apache License 2.0 4 votes vote down vote up
@Override public CastOptions getCastOptions(Context context) {
  return new CastOptions.Builder()
      .setReceiverApplicationId(BuildConfig.CAST_APP_ID)
      .build();
}
 
Example #18
Source File: CastOptionsProvider.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
@Override
public CastOptions getCastOptions(Context context) {
    return new CastOptions.Builder()
            .setReceiverApplicationId(SecretKeys.CHROME_CAST_APPLICATION_ID)
            .build();
}
 
Example #19
Source File: Casty.java    From Casty with MIT License 2 votes vote down vote up
/**
 * Sets the custom CastOptions, should be used in the {@link Application} class.
 *
 * @param castOptions the custom CastOptions object, must include a receiver ID
 */
public static void configure(@NonNull CastOptions castOptions) {
    Casty.customCastOptions = castOptions;
}