本文整理匯總了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);
}
示例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);
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}
示例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!");
}
});
}
示例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);
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}