Last active
January 31, 2019 13:34
-
-
Save luizguilhermefr/c1ca46f9656e6d7edbf6d2bcbb622c2e to your computer and use it in GitHub Desktop.
Chromecast Sender Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.luizguilhermefr.castcastcast; | |
import android.content.Context; | |
import android.text.format.DateUtils; | |
import com.google.android.gms.cast.framework.CastOptions; | |
import com.google.android.gms.cast.framework.OptionsProvider; | |
import com.google.android.gms.cast.framework.SessionProvider; | |
import com.google.android.gms.cast.framework.media.CastMediaOptions; | |
import com.google.android.gms.cast.framework.media.MediaIntentReceiver; | |
import com.google.android.gms.cast.framework.media.NotificationOptions; | |
import java.util.ArrayList; | |
import java.util.List; | |
import io.github.luizguilhermefr.castcastcast.ExpandedControlsActivity; | |
@SuppressWarnings("unused") | |
public class CastOptionsProvider implements OptionsProvider { | |
@Override | |
public CastOptions getCastOptions(Context context) { | |
final String RECEIVER_APP_ID = context.getString(R.string.chromecast_receiver_app_id); | |
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); | |
int[] compatButtonActionsIndices = new int[]{1, 3}; | |
NotificationOptions notificationOptions = new NotificationOptions.Builder() | |
.setTargetActivityClassName(ExpandedControlsActivity.class.getName()) | |
.setActions(buttonActions, compatButtonActionsIndices) | |
.setSkipStepMs(30 * DateUtils.SECOND_IN_MILLIS) | |
.build(); | |
CastMediaOptions mediaOptions = new CastMediaOptions.Builder() | |
.setNotificationOptions(notificationOptions) | |
.setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName()) | |
.build(); | |
return new CastOptions.Builder() | |
.setReceiverApplicationId(RECEIVER_APP_ID) | |
.setCastMediaOptions(mediaOptions) | |
.build(); | |
} | |
@Override | |
public List<SessionProvider> getAdditionalSessionProviders(Context context) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment