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


Java MediaRouteSelector類代碼示例

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


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

示例1: setupMediaRouter

import android.support.v7.media.MediaRouteSelector; //導入依賴的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: BaseCastManager

import android.support.v7.media.MediaRouteSelector; //導入依賴的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);
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:23,代碼來源:BaseCastManager.java

示例3: start

import android.support.v7.media.MediaRouteSelector; //導入依賴的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();
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:26,代碼來源:CastDiscoveryProvider.java

示例4: testStart

import android.support.v7.media.MediaRouteSelector; //導入依賴的package包/類
@Test
public void testStart() throws Exception {
    // TEST DESC.: start method should invoke MediaRouter removeCallback and addCalback
    // for stopping and starting services

    // when
    dp.start();

    // waiting for timer call
    Thread.sleep(200);
    Robolectric.runUiThreadTasksIncludingDelayedTasks();

    // then
    verify(mediaRouter).addCallback(any(MediaRouteSelector.class),
            any(MediaRouter.Callback.class), eq(MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY));
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:17,代碼來源:CastDiscoveryProviderTest.java

示例5: prepareCastButton

import android.support.v7.media.MediaRouteSelector; //導入依賴的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);
}
 
開發者ID:ankyl,項目名稱:castscreen,代碼行數:25,代碼來源:CastScreenActivity.java

示例6: BaseCastManager

import android.support.v7.media.MediaRouteSelector; //導入依賴的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);
}
 
開發者ID:BruGTUG,項目名稱:codelab-chromecast,代碼行數:19,代碼來源:BaseCastManager.java

示例7: onCreate

import android.support.v7.media.MediaRouteSelector; //導入依賴的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!");
        }
    });
}
 
開發者ID:roys,項目名稱:cast-codelab,代碼行數:23,代碼來源:CastActivity.java

示例8: onResume

import android.support.v7.media.MediaRouteSelector; //導入依賴的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);
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:18,代碼來源:MediaPlayerManager.java

示例9: onCreate

import android.support.v7.media.MediaRouteSelector; //導入依賴的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();
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:26,代碼來源:BaseActivity.java

示例10: onCreate

import android.support.v7.media.MediaRouteSelector; //導入依賴的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();
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:27,代碼來源:DevicePickerActivity.java

示例11: onCreate

import android.support.v7.media.MediaRouteSelector; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(
            getResources().getColor(android.R.color.transparent)));

    // When the user clicks on the button, use Android voice recognition to
    // get text
    Button voiceButton = (Button) findViewById(R.id.voiceButton);
    voiceButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            startVoiceRecognitionActivity();
        }
    });

    // Configure Cast device discovery
    mMediaRouter = MediaRouter.getInstance(getApplicationContext());
    mMediaRouteSelector = new MediaRouteSelector.Builder()
            .addControlCategory(CastMediaControlIntent.categoryForCast(getResources()
                    .getString(R.string.app_id))).build();
    mMediaRouterCallback = new MyMediaRouterCallback();
}
 
開發者ID:googlecast,項目名稱:CastHelloText-android-v2,代碼行數:27,代碼來源:MainActivity.java

示例12: initRouters

import android.support.v7.media.MediaRouteSelector; //導入依賴的package包/類
private void initRouters(CallbackContext callbackContext) {
    Log.d(TAG, "init routers...");

    mMediaRouter = MediaRouter.getInstance(cordova.getActivity().getApplicationContext());
    mMediaRouteSelector = new MediaRouteSelector.Builder()
            .addControlCategory(CastMediaControlIntent.categoryForCast(APP_ID))
            .build();
    mMediaRouterCallback = new MyMediaRouterCallback();

    mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
            MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);

    if (callbackContext != null) {
        callbackContext.success();
    }
}
 
開發者ID:SesamTV,項目名稱:ChromecastCordova,代碼行數:17,代碼來源:ChromeCast.java

示例13: BaseCastManager

import android.support.v7.media.MediaRouteSelector; //導入依賴的package包/類
/**
 * ********************************************************************
 */

protected BaseCastManager(Context context, String applicationId) {
  CastUtils.LOGD(TAG, "BaseCastManager is instantiated");
  mContext = context;
  mHandler = new Handler(Looper.getMainLooper());
  mApplicationId = applicationId;
  CastUtils.saveStringToPreference(mContext, PREFS_KEY_APPLICATION_ID, applicationId);

  CastUtils.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_PERFORM_ACTIVE_SCAN);
}
 
開發者ID:sgehrman,項目名稱:UTubeTV,代碼行數:20,代碼來源:BaseCastManager.java

示例14: BaseCastManager

import android.support.v7.media.MediaRouteSelector; //導入依賴的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());
        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_PERFORM_ACTIVE_SCAN);
    }
 
開發者ID:TByron,項目名稱:Jupiter-Broadcasting-Holo,代碼行數:20,代碼來源:BaseCastManager.java

示例15: onCreate

import android.support.v7.media.MediaRouteSelector; //導入依賴的package包/類
@Override
public void onCreate() {
	super.onCreate();
	mMediaRouter = MediaRouter.getInstance(this);
	pollStatus();

	PhoneCallListener phoneListener = new PhoneCallListener();
	TelephonyManager telephonyManager =
			(TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
	telephonyManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);

	MediaRouteSelector selector = new MediaRouteSelector.Builder()
			.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
			.build();
	mMediaRouter.addCallback(selector, mMediaRouterCallback,
			MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
 
開發者ID:Nutomic,項目名稱:controldlna,代碼行數:18,代碼來源:MediaRouterPlayService.java


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