本文整理汇总了Java中android.support.v7.media.MediaRouter.RouteInfo方法的典型用法代码示例。如果您正苦于以下问题:Java MediaRouter.RouteInfo方法的具体用法?Java MediaRouter.RouteInfo怎么用?Java MediaRouter.RouteInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.media.MediaRouter
的用法示例。
在下文中一共展示了MediaRouter.RouteInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRouteSelected
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteSelected(MediaRouter router, MediaRouter.RouteInfo route) {
Log.d(TAG, "onRouteSelected: route=" + route);
if (route.supportsControlCategory(
MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)){
// Stop local playback (if necessary)
// ...
// Save the new route
mRoute = route;
// Attach a new playback client
mRemotePlaybackClient = new RemotePlaybackClient(getBaseContext(), mRoute);
// Start remote playback (if necessary)
// ...
}
}
示例2: onRouteUnselected
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteUnselected(MediaRouter router, MediaRouter.RouteInfo route, int reason) {
Log.d(TAG, "onRouteUnselected: route=" + route);
if (route.supportsControlCategory(
MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)){
// Changed route: tear down previous client
if (mRoute != null && mRemotePlaybackClient != null) {
mRemotePlaybackClient.release();
mRemotePlaybackClient = null;
}
// Save the new route
mRoute = route;
if (reason != MediaRouter.UNSELECT_REASON_ROUTE_CHANGED) {
// Resume local playback (if necessary)
// ...
}
}
}
示例3: onCastDeviceDetected
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onCastDeviceDetected(final MediaRouter.RouteInfo info) {
// FTU stands for First Time Use:
if (!PrefUtils.isFtuShown(ActionBarCastActivity.this)) {
// If user is seeing the cast button for the first time, we will
// show an overlay that explains what that button means.
PrefUtils.setFtuShown(ActionBarCastActivity.this, true);
LogHelper.d(TAG, "Route is visible: ", info);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (mMediaRouteMenuItem.isVisible()) {
LogHelper.d(TAG, "Cast Icon is visible: ", info.getName());
showFtu();
}
}
}, DELAY_MILLIS);
}
}
示例4: showDialog
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public boolean showDialog() {
try {
Activity currentActivity = getActivity();
final FragmentManager fm = ((FragmentActivity) currentActivity).getSupportFragmentManager();
if (!isAttachedToWindow()
|| (fm.findFragmentByTag(CONTROLLER_TAG) != null)
|| (fm.findFragmentByTag(CHOOSER_TAG) != null) ) {
return false;
}
MediaRouter.RouteInfo route = getMediaRouter().getSelectedRoute();
if (route.isDefault() || !route.matchesSelector(mSelector)) { // route chooser
Intent intent = ((MediaProjectionManager)
currentActivity.getSystemService(Context.MEDIA_PROJECTION_SERVICE)).createScreenCaptureIntent();
currentActivity.startActivityForResult(intent, CastScreenActivity.SCREEN_CAPTURE_REQUEST);
return true;
} else { // route controller
return super.showDialog();
}
} catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
Log.e(TAG, "MediaRouteButton implementation changed - " + CastScreenActivity.PLEASE_REPORT_BUG);
}
return false;
}
示例5: selectDevice
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
/**
* Tries to select a device with the given device ID. The device ID is cached so that if the
* route does not exist yet, we will connect to it as soon as it comes back up again
*
* @param deviceId the ID of the device to connect to
*/
private void selectDevice(String deviceId) {
if (deviceId == null) {
release();
return;
}
setDeviceId(deviceId);
if (mDebug) Log.d(TAG, "Trying to select " + getDeviceId());
// See if we can select the device at this point.
if (getMediaRouter() != null) {
for (MediaRouter.RouteInfo route : getMediaRouter().getRoutes()) {
if (deviceId.equals(route.getId())) {
route.select();
break;
}
}
}
}
示例6: fromRoute
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
/**
* @param route The route information provided by Android.
* @return A new MediaSink instance corresponding to the specified {@link RouteInfo}.
*/
public static MediaSink fromRoute(MediaRouter.RouteInfo route) {
return new MediaSink(
route.getId(),
route.getName(),
CastDevice.getFromBundle(route.getExtras()));
}
示例7: fromSinkId
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
/**
* @param sinkId The id of the sink to find among known media routes.
* @param router The instance of {@link MediaRouter} to enumerate the routes with.
* @return A {@link MediaSink} corresponding to the {@link RouteInfo} with the specified id if
* found, null otherwise.
*/
@Nullable
public static MediaSink fromSinkId(String sinkId, MediaRouter router) {
for (MediaRouter.RouteInfo route : router.getRoutes()) {
MediaSink sink = MediaSink.fromRoute(route);
if (sink.getId().equals(sinkId)) return sink;
}
return null;
}
示例8: onRouteAdded
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteAdded(MediaRouter router, MediaRouter.RouteInfo route) {
if (route == null || !route.matchesSelector(mRouteSelector)) return;
MediaSink sink = MediaSink.fromRoute(route);
if (mSinks.contains(sink)) return;
mSinks.add(sink);
updateChromeMediaRouter();
}
示例9: onRouteRemoved
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteRemoved(MediaRouter router, MediaRouter.RouteInfo route) {
MediaSink sink = MediaSink.fromRoute(route);
if (!mSinks.contains(sink)) return;
mSinks.remove(sink);
updateChromeMediaRouter();
}
示例10: onRouteChanged
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteChanged(MediaRouter router, MediaRouter.RouteInfo route) {
// Sometimes onRouteAdded is not called for the route as it doesn't yet match the selector.
// onRouteChanged() will be called later when the matching category is added.
if (route == null) return;
if (route.matchesSelector(mRouteSelector)) {
onRouteAdded(router, route);
} else {
onRouteRemoved(router, route);
}
}
示例11: setSelectedRoute
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
public void setSelectedRoute(MediaRouter.RouteInfo device){
mSelectedRoute = device;
if(CastDebug.DBG){
CastDebug.log("setSelectedRoute: device is null ?"+(device==null));
}
if(device==null)
onDisconnect();
}
示例12: createApiClient
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
private GoogleApiClient createApiClient(
MediaRouter.RouteInfo route, Cast.Listener listener, Context context) {
CastDevice selectedDevice = CastDevice.getFromBundle(route.getExtras());
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(selectedDevice, listener)
// TODO(avayvod): hide this behind the flag or remove
.setVerboseLoggingEnabled(true);
return new GoogleApiClient.Builder(context)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
示例13: onRouteUnselected
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteUnselected(MediaRouter router, MediaRouter.RouteInfo info) {
if (isRemoteDisplaying()) {
CastRemoteDisplayLocalService.stopService();
}
castDevice = null;
}
示例14: onRouteSelected
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteSelected(MediaRouter router, MediaRouter.RouteInfo info) {
Log.d(TAG, "onRouteSelected");
// Handle the user route selection.
mSelectedDevice = CastDevice.getFromBundle(info.getExtras());
launchReceiver();
}
示例15: onRouteAdded
import android.support.v7.media.MediaRouter; //导入方法依赖的package包/类
@Override
public void onRouteAdded(final MediaRouter router, final MediaRouter.RouteInfo route) {
Log.d(TAG, "Route added: " + route.getName());
if (mRouteId != null && mRouteInfo == null && mRouteId.equals(route.getId())) {
restoreRoute();
}
}