本文整理汇总了Java中com.google.android.gms.cast.CastMediaControlIntent类的典型用法代码示例。如果您正苦于以下问题:Java CastMediaControlIntent类的具体用法?Java CastMediaControlIntent怎么用?Java CastMediaControlIntent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CastMediaControlIntent类属于com.google.android.gms.cast包,在下文中一共展示了CastMediaControlIntent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupMediaRouter
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
private void setupMediaRouter() {
mediaRouter = MediaRouter.getInstance(getApplicationContext());
mediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(
CastMediaControlIntent.categoryForCast(getString(R.string.app_cast_id))).build();
if (isRemoteDisplaying()) {
this.castDevice = CastDevice.getFromBundle(mediaRouter.getSelectedRoute().getExtras());
} else {
Bundle extras = getIntent().getExtras();
if (extras != null) {
castDevice = extras.getParcelable(INTENT_EXTRA_CAST_DEVICE);
}
}
mediaRouter.addCallback(mediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
示例2: getCastOptions
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
@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;
}
示例3: startSession
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
/**
* Send a start session intent.
*
* @param relaunch Whether we should relaunch the cast application.
* @param resultBundleHandler BundleHandler to handle reply.
*/
private void startSession(boolean relaunch, String sessionId,
ResultBundleHandler resultBundleHandler) {
Intent intent = new Intent(MediaControlIntent.ACTION_START_SESSION);
intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS, true);
intent.putExtra(MediaControlIntent.EXTRA_SESSION_STATUS_UPDATE_RECEIVER,
mSessionStatusUpdateIntent);
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_APPLICATION_ID, getCastReceiverId());
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_RELAUNCH_APPLICATION, relaunch);
if (sessionId != null) intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, sessionId);
addIntentExtraForDebugLogging(intent);
sendIntentToRoute(intent, resultBundleHandler);
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:DefaultMediaRouteController.java
示例4: BaseCastManager
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
protected BaseCastManager(Context context, CastConfiguration castConfiguration) {
mCastConfiguration = castConfiguration;
mCapabilities = castConfiguration.getCapabilities();
LogUtils.setDebug(isFeatureEnabled(CastConfiguration.FEATURE_DEBUGGING));
sCclVersion = context.getString(R.string.ccl_version);
mApplicationId = castConfiguration.getApplicationId();
LOGD(TAG, "BaseCastManager is instantiated\nVersion: " + sCclVersion
+ "\nApplication ID: " + mApplicationId);
mContext = context.getApplicationContext();
mPreferenceAccessor = new PreferenceAccessor(mContext);
mUiVisibilityHandler = new Handler(new UpdateUiVisibilityHandlerCallback());
mPreferenceAccessor.saveStringToPreference(PREFS_KEY_APPLICATION_ID, mApplicationId);
mMediaRouter = MediaRouter.getInstance(mContext);
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(
CastMediaControlIntent.categoryForCast(mApplicationId)).build();
mMediaRouterCallback = new CastMediaRouterCallback(this);
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
示例5: start
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
@Override
public void start() {
if (isRunning)
return;
isRunning = true;
if (mMediaRouteSelector == null) {
try {
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(CastMediaControlIntent.categoryForCast(
CastService.getApplicationID()))
.build();
} catch (IllegalArgumentException e) {
Log.w(Util.T, "Invalid application ID: " + CastService.getApplicationID());
for (DiscoveryProviderListener listener : serviceListeners) {
listener.onServiceDiscoveryFailed(this, new ServiceCommandError(0,
"Invalid application ID: " + CastService.getApplicationID(), null));
}
return;
}
}
rescan();
}
示例6: prepareCastButton
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
/**
* sets up the Cast button and starts route discovery
* @param castMenuItem the MenuItem holding a {@link CastScreenMediaRouteActionProvider}
* @param appId id for a Remote Display Receiver application
*/
protected void prepareCastButton(MenuItem castMenuItem, String appId) {
mSelector = new MediaRouteSelector.Builder().addControlCategory(
CastMediaControlIntent.categoryForCast(appId)
).build();
mProvider = (CastScreenMediaRouteActionProvider)
MenuItemCompat.getActionProvider(castMenuItem);
mProvider.setRouteSelector(mSelector);
mAppId = appId;
mRouter = MediaRouter.getInstance(getApplicationContext());
// Remove existing callback if present
if(mCallback != null)
mRouter.removeCallback(mCallback);
mCallback = new MediaRouterCallback();
mRouter.addCallback(mSelector, mCallback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
示例7: joinSession
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
private void joinSession() {
try {
Cast.CastApi
.joinApplication(mApiClient,
CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID,
mSessionId)
.setResultCallback(
new ResultCallback<Cast.ApplicationConnectionResult>() {
@Override
public void onResult(
@NonNull final Cast.ApplicationConnectionResult result) {
Status status = result.getStatus();
if (status.isSuccess()) {
Log.i(TAG, "Joined session: " + mRouteInfo.getName());
setApplicationStarted(true);
mMediaRouter.selectRoute(mRouteInfo);
connectRemoteMediaPlayer();
} else {
teardown();
}
}
});
} catch (Exception e) {
Log.e(TAG, "Failed to join application", e);
}
}
示例8: startSession
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
/**
* Send a start session intent.
*
* @param relaunch Whether we should relaunch the cast application.
* @param resultBundleHandler BundleHandler to handle reply.
*/
private void startSession(boolean relaunch, String sessionId,
ResultBundleHandler resultBundleHandler) {
Intent intent = new Intent(MediaControlIntent.ACTION_START_SESSION);
intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS, true);
intent.putExtra(MediaControlIntent.EXTRA_SESSION_STATUS_UPDATE_RECEIVER,
mSessionStatusUpdateIntent);
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_APPLICATION_ID, getCastReceiverId());
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_RELAUNCH_APPLICATION, relaunch);
if (sessionId != null) intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, sessionId);
if (mDebug) intent.putExtra(CastMediaControlIntent.EXTRA_DEBUG_LOGGING_ENABLED, true);
sendIntentToRoute(intent, resultBundleHandler);
}
示例9: BaseCastManager
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
protected BaseCastManager(Context context, String applicationId) {
CCL_VERSION = context.getString(R.string.ccl_version);
LOGD(TAG, "BaseCastManager is instantiated");
mContext = context;
mHandler = new Handler(Looper.getMainLooper());
mUiVisibilityHandler = new Handler(new UpdateUiVisibilityHandlerCallback());
mApplicationId = applicationId;
Utils.saveStringToPreference(mContext, PREFS_KEY_APPLICATION_ID, applicationId);
LOGD(TAG, "Application ID is: " + mApplicationId);
mMediaRouter = MediaRouter.getInstance(context);
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(
CastMediaControlIntent.categoryForCast(mApplicationId)).build();
mMediaRouterCallback = new CastMediaRouterCallback(this, context);
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
示例10: onCreate
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cast);
// Step 2
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
// Step 3
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(CastMediaControlIntent.categoryForCast(APPID)).build();
// Some step (was missing)
mMediaRouterCallback = new MyMediaRouterCallback();
Button sendMessageButton = (Button) findViewById(R.id.button);
sendMessageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendCommand("Yey, it can has works!");
}
});
}
示例11: onResume
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
// The mediaRouter shouldn't exist here, but this is a nice safety check.
if (mediaRouter != null) {
return;
}
mediaRouter = MediaRouter.getInstance(getActivity());
final MediaRouteSelector selectorBuilder = new MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.addControlCategory(CastMediaControlIntent.categoryForCast(ChromeCast.MIRROR_RECEIVER_APP_ID))
.build();
mediaRouter.addCallback(selectorBuilder, callback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
示例12: onCreate
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Bind Apollo's service
mMusicService.bind();
// Control the media volume
setVolumeControlStream(AudioManager.STREAM_MUSIC);
isCastingEnabled = checkCastingEnabled();
if (isCastingEnabled) {
// Bind cast service
mCastServiceToken = RemoteCastServiceManager.bindToService(this,
new Messenger(new CastManagerCallbackHandler(this)),
null);
// Initialize the media router
mMediaRouter = MediaRouter.getInstance(this);
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(CastMediaControlIntent.categoryForCast(getString(R.string.cast_id)))
//.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
.build();
}
}
示例13: onCreate
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
@Override
@DebugLog
protected void onCreate(Bundle savedInstanceState) {
boolean light = getIntent().getBooleanExtra(RendererConstants.EXTRA_WANT_LIGHT_THEME, true);
setTheme(light ? R.style.CastThemeTranslucentLight : R.style.CastThemeTranslucentDark);
super.onCreate(savedInstanceState);
CastComponent parent = DaggerService.getDaggerComponent(getApplicationContext());
DevicePickerActivityComponent.FACTORY.call(parent).inject(this);
setResult(RESULT_CANCELED, new Intent());
//always reset route
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
final MediaRouteSelector selector = new MediaRouteSelector.Builder()
.addControlCategory(CastMediaControlIntent.categoryForCast(getString(R.string.cast_id)))
.build();
mCallback = new MediaRouterCallback();
mMediaRouter.addCallback(selector, mCallback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
mDialog = new MediaRouteChooserDialog(this);
mDialog.setOnDismissListener(this);
mDialog.setRouteSelector(selector);
mDialog.show();
}
示例14: startSession
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
private void startSession() {
Intent intent = new Intent(MediaControlIntent.ACTION_START_SESSION);
intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
intent.putExtra(MediaControlIntent.EXTRA_SESSION_STATUS_UPDATE_RECEIVER,
mSessionStatusUpdateIntent);
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_APPLICATION_ID,
getReceiverApplicationId());
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_RELAUNCH_APPLICATION,
getRelaunchApp());
intent.putExtra(CastMediaControlIntent.EXTRA_DEBUG_LOGGING_ENABLED, true);
if (getStopAppWhenEndingSession()) {
intent.putExtra(CastMediaControlIntent.EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS,
true);
}
sendIntentToRoute(intent, new ResultBundleHandler() {
@Override
public void handleResult(Bundle bundle) {
mSessionId = bundle.getString(MediaControlIntent.EXTRA_SESSION_ID);
Log.d(TAG, "Got a session ID of: " + mSessionId);
}
});
}
示例15: initializeCastManager
import com.google.android.gms.cast.CastMediaControlIntent; //导入依赖的package包/类
public static VideoCastManager initializeCastManager(Context context) {
CastConfiguration.Builder builder = new CastConfiguration.Builder(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
.enableAutoReconnect()
.enableCaptionManagement()
.enableWifiReconnection();
if(BuildConfig.DEBUG){
builder.enableDebug();
}
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if(preferences.getBoolean("chromecast_lock_screen", true)){
builder.enableLockScreen();
}
if(preferences.getBoolean("chromecast_notification", true)){
builder.enableNotification()
.addNotificationAction(CastConfiguration.NOTIFICATION_ACTION_PLAY_PAUSE, true)
.addNotificationAction(CastConfiguration.NOTIFICATION_ACTION_DISCONNECT, true);
}
return VideoCastManager.initialize(context, builder.build());
}