當前位置: 首頁>>代碼示例>>Java>>正文


Java CastDevice類代碼示例

本文整理匯總了Java中com.google.android.gms.cast.CastDevice的典型用法代碼示例。如果您正苦於以下問題:Java CastDevice類的具體用法?Java CastDevice怎麽用?Java CastDevice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CastDevice類屬於com.google.android.gms.cast包,在下文中一共展示了CastDevice類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupMediaRouter

import com.google.android.gms.cast.CastDevice; //導入依賴的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);
}
 
開發者ID:ferranpons,項目名稱:android-cast-remote-display-sample,代碼行數:17,代碼來源:MainActivity.java

示例2: getCapabilities

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
/**
 * @param device The {@link CastDevice} queried for it's capabilities.
 * @return The capabilities of the Cast device.
 * TODO(zqzhang): move to a CastUtils class?
 */
protected static List<String> getCapabilities(CastDevice device) {
    List<String> capabilities = new ArrayList<String>();
    if (device.hasCapability(CastDevice.CAPABILITY_AUDIO_IN)) {
        capabilities.add("audio_in");
    }
    if (device.hasCapability(CastDevice.CAPABILITY_AUDIO_OUT)) {
        capabilities.add("audio_out");
    }
    if (device.hasCapability(CastDevice.CAPABILITY_VIDEO_IN)) {
        capabilities.add("video_in");
    }
    if (device.hasCapability(CastDevice.CAPABILITY_VIDEO_OUT)) {
        capabilities.add("video_out");
    }
    return capabilities;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:22,代碼來源:CastSessionImpl.java

示例3: setDevice

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
private void setDevice(CastDevice device) {
    mSelectedCastDevice = device;
    mDeviceName = mSelectedCastDevice.getFriendlyName();

    if (mApiClient == null) {
        LOGD(TAG, "acquiring a connection to Google Play services for " + mSelectedCastDevice);
        Cast.CastOptions.Builder apiOptionsBuilder = getCastOptionBuilder(mSelectedCastDevice);
        mApiClient = new GoogleApiClient.Builder(mContext)
                .addApi(Cast.API, apiOptionsBuilder.build())
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
        mApiClient.connect();
    } else if (!mApiClient.isConnected() && !mApiClient.isConnecting()) {
        mApiClient.connect();
    }
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:18,代碼來源:BaseCastManager.java

示例4: reconnectSessionIfPossibleInternal

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
private void reconnectSessionIfPossibleInternal(RouteInfo theRoute) {
    if (isConnected()) {
        return;
    }
    String sessionId = mPreferenceAccessor.getStringFromPreference(PREFS_KEY_SESSION_ID);
    String routeId = mPreferenceAccessor.getStringFromPreference(PREFS_KEY_ROUTE_ID);
    LOGD(TAG, "reconnectSessionIfPossible() Retrieved from preferences: " + "sessionId="
            + sessionId + ", routeId=" + routeId);
    if (sessionId == null || routeId == null) {
        return;
    }
    setReconnectionStatus(RECONNECTION_STATUS_IN_PROGRESS);
    CastDevice device = CastDevice.getFromBundle(theRoute.getExtras());

    if (device != null) {
        LOGD(TAG, "trying to acquire Cast Client for " + device);
        onDeviceSelected(device, theRoute);
    }
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:20,代碼來源:BaseCastManager.java

示例5: onRouteSelected

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
@Override
public void onRouteSelected(MediaRouter router, RouteInfo info) {
    LOGD(TAG, "onRouteSelected: info=" + info);
    if (mCastManager.getReconnectionStatus()
            == BaseCastManager.RECONNECTION_STATUS_FINALIZED) {
        mCastManager.setReconnectionStatus(BaseCastManager.RECONNECTION_STATUS_INACTIVE);
        mCastManager.cancelReconnectionTask();
        return;
    }
    mCastManager.getPreferenceAccessor().saveStringToPreference(
            BaseCastManager.PREFS_KEY_ROUTE_ID, info.getId());
    CastDevice device = CastDevice.getFromBundle(info.getExtras());
    mCastManager.onDeviceSelected(device, info);
    LOGD(TAG, "onRouteSelected: mSelectedDevice=" + (device != null ? device.getFriendlyName()
            : "Null"));
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:17,代碼來源:CastMediaRouterCallback.java

示例6: onRouteAdded

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
@Override
public void onRouteAdded(MediaRouter router, RouteInfo routeInfo) {
    if (!router.getDefaultRoute().equals(routeInfo)) {
        notifyRouteAvailabilityChangedIfNeeded(router);
        mCastManager.onCastDeviceDetected(routeInfo);
    }
    if (mCastManager.getReconnectionStatus()
            == BaseCastManager.RECONNECTION_STATUS_STARTED) {
        String routeId = mCastManager.getPreferenceAccessor().getStringFromPreference(
                BaseCastManager.PREFS_KEY_ROUTE_ID);
        if (routeInfo.getId().equals(routeId)) {
            // we found the route, so lets go with that
            LOGD(TAG, "onRouteAdded: Attempting to recover a session with info=" + routeInfo);
            mCastManager.setReconnectionStatus(BaseCastManager.RECONNECTION_STATUS_IN_PROGRESS);

            CastDevice device = CastDevice.getFromBundle(routeInfo.getExtras());
            LOGD(TAG, "onRouteAdded: Attempting to recover a session with device: "
                    + (device != null ? device.getFriendlyName() : "Null"));
            mCastManager.onDeviceSelected(device, routeInfo);
        }
    }
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:23,代碼來源:CastMediaRouterCallback.java

示例7: onRouteRemoved

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
@Override
public void onRouteRemoved(final MediaRouter router, final RouteInfo route) {
    super.onRouteRemoved(router, route);

    CastDevice castDevice = CastDevice.getFromBundle(route.getExtras());
    String uuid = castDevice.getDeviceId();
    removedUUID.add(uuid);

    // Prevent immediate removing. There are some cases when service is removed and added
    // again after a second.
    if (removeRoutesTimer == null) {
        removeRoutesTimer = new Timer();
        removeRoutesTimer.schedule(new TimerTask() {
            @Override
            public void run() {
                removeServices(route);
            }
        }, ROUTE_REMOVE_INTERVAL);
    }
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:21,代碼來源:CastDiscoveryProvider.java

示例8: onRouteSelected

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
@Override
public void onRouteSelected(MediaRouter router, MediaRouter.RouteInfo route) {
    // start casting when the user selects a media route
    CastDevice device = CastDevice.getFromBundle(route.getExtras());
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    CastScreenService.start(getApplicationContext(),
        mAppId,
        metrics,
        mPermissionsResultCode,
        mPermissionsData,
        device,
        mRouter,
        CastScreenService.makeNotification(CastScreenActivity.this, device)
    );
}
 
開發者ID:ankyl,項目名稱:castscreen,代碼行數:18,代碼來源:CastScreenActivity.java

示例9: ConnectionManager

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
public ConnectionManager(Context context,
                          DisplayMetrics metrics,
                          int permissionsResultCode,
                          Intent permissionsData,
                          CastDevice device,
                          CastScreenService service,
                          MediaRouter router,
                          String appId) {
    mProjectionManager = new ProjectionManager(context, metrics, permissionsResultCode, permissionsData, router);
    mRouter = router;
    mStopCallback = new StopCallback();

    mService = service;
    mMainHandler = new Handler(service.getMainLooper());
    mAppContext = context;
    mAppId = appId;

    mApiClient = createApiClient(device);
}
 
開發者ID:ankyl,項目名稱:castscreen,代碼行數:20,代碼來源:ConnectionManager.java

示例10: initialize

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
/**
 * connect to the cast device and start showing the notification controller
 */
private void initialize(Context context,
                        String appId,
                        ServiceConnection connection,
                        DisplayMetrics metrics,
                        int permissionsResultCode,
                        Intent permissionsData,
                        CastDevice device,
                        MediaRouter router,
                        Notification notification) {
    mConnectionManager = new ConnectionManager(context, metrics, permissionsResultCode,
            permissionsData, device, this, router, appId);
    mConnectionManager.connect();
    mAppContext = context;
    mServiceConnection = connection;

    startForeground(com.google.android.gms.R.id.cast_notification_id, notification);
    sCastScreenService = this;
}
 
開發者ID:ankyl,項目名稱:castscreen,代碼行數:22,代碼來源:CastScreenService.java

示例11: onMessageReceived

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
@Override
public void onMessageReceived(CastDevice castDevice, String namespace, final String message) {
    if (session.getWebAppSessionListener() == null)
        return;

    JSONObject messageJSON = null;

    try {
        messageJSON = new JSONObject(message);
    } catch (JSONException e) { }

    final JSONObject mMessage = messageJSON;

    Util.runOnUI(new Runnable() {

        @Override
        public void run() {
            if (mMessage == null) {
                session.getWebAppSessionListener().onReceiveMessage(session, message);
            } else {
                session.getWebAppSessionListener().onReceiveMessage(session, mMessage);
            }
        }
    });
}
 
開發者ID:PTCE,項目名稱:popcorn-android,代碼行數:26,代碼來源:CastServiceChannel.java

示例12: onCastDeviceUpdate

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
@Override
public void onCastDeviceUpdate(final ArrayList<CastDevice> devices) {
    if (BuildConfig.DEBUG) {
        Log.d("TEST", "onCastDeviceUpdate#");
    }
    if (devices.size() == 0) {
        if (BuildConfig.DEBUG) {
            Log.d("TEST", "size:0");
        }
        ChromeCastApplication app = (ChromeCastApplication) getApplication();

        if (app.getController() != null) {
            app.getController().teardown();
        }
    }
}
 
開發者ID:DeviceConnect,項目名稱:DeviceConnect-Android,代碼行數:17,代碼來源:ChromeCastService.java

示例13: onDeviceSelected

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
@Override
public void onDeviceSelected(CastDevice device) {
    if (null == device) {
        disconnectDevice(mDestroyOnDisconnect, true, false);
    } else {
        setDevice(device);
    }
    synchronized (mBaseCastConsumers) {
        for (IBaseCastConsumer consumer : mBaseCastConsumers) {
            try {
                consumer.onDeviceSelected(device);
            } catch (Exception e) {
                LOGE(TAG, "onDeviceSelected(): Failed to inform " + consumer, e);
            }
        }
    }
}
 
開發者ID:BruGTUG,項目名稱:codelab-chromecast,代碼行數:18,代碼來源:BaseCastManager.java

示例14: setDevice

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
public void setDevice(CastDevice device) {
    mSelectedCastDevice = device;
    mDeviceName = mSelectedCastDevice.getFriendlyName();

    if (null == mApiClient) {
        LOGD(TAG, "acquiring a connection to Google Play services for " + mSelectedCastDevice);
        Cast.CastOptions.Builder apiOptionsBuilder = getCastOptionBuilder(mSelectedCastDevice);
        mApiClient = new GoogleApiClient.Builder(mContext)
                .addApi(Cast.API, apiOptionsBuilder.build())
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
        mApiClient.connect();
    } else if (!mApiClient.isConnected() && !mApiClient.isConnecting()) {
        mApiClient.connect();
    }
}
 
開發者ID:BruGTUG,項目名稱:codelab-chromecast,代碼行數:18,代碼來源:BaseCastManager.java

示例15: reconnectSessionIfPossibleInternal

import com.google.android.gms.cast.CastDevice; //導入依賴的package包/類
private void reconnectSessionIfPossibleInternal(RouteInfo theRoute) {
    if (isConnected()) {
        onReconnectionStatusChanged(RECONNECTION_SUCCESSFUL);
        return;
    }
    String sessionId = Utils.getStringFromPreference(mContext, PREFS_KEY_SESSION_ID);
    String routeId = Utils.getStringFromPreference(mContext, PREFS_KEY_ROUTE_ID);
    LOGD(TAG, "reconnectSessionIfPossible() Retrieved from preferences: " + "sessionId="
            + sessionId + ", routeId=" + routeId);
    if (null == sessionId || null == routeId) {
        return;
    }
    mReconnectionStatus = ReconnectionStatus.IN_PROGRESS;
    CastDevice device = CastDevice.getFromBundle(theRoute.getExtras());

    if (null != device) {
        LOGD(TAG, "trying to acquire Cast Client for " + device);
        onDeviceSelected(device);
    }
}
 
開發者ID:BruGTUG,項目名稱:codelab-chromecast,代碼行數:21,代碼來源:BaseCastManager.java


注:本文中的com.google.android.gms.cast.CastDevice類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。