当前位置: 首页>>代码示例>>Java>>正文


Java MediaRouteButton.setRouteSelector方法代码示例

本文整理汇总了Java中android.support.v7.app.MediaRouteButton.setRouteSelector方法的典型用法代码示例。如果您正苦于以下问题:Java MediaRouteButton.setRouteSelector方法的具体用法?Java MediaRouteButton.setRouteSelector怎么用?Java MediaRouteButton.setRouteSelector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.app.MediaRouteButton的用法示例。


在下文中一共展示了MediaRouteButton.setRouteSelector方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startDeviceScan

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
private void startDeviceScan() {
	MediaRouteHelper.registerMinimalMediaRouteProvider(
			mService.getCastContext(), this);
	mMediaRouter = MediaRouter.getInstance(getApplicationContext());
	mMediaRouteSelector = MediaRouteHelper.buildMediaRouteSelector(
			MediaRouteHelper.CATEGORY_CAST, null, null);

	mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
	mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
	// mMediaRouteButton.setDialogFactory(mDialogFactory);
	mMediaRouterCallback = new MyMediaRouterCallback();

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

}
 
开发者ID:dougnlamb,项目名称:FireCast,代码行数:17,代码来源:SetupCastSessionActivity.java

示例2: addMediaRouterButton

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
public void addMediaRouterButton(Menu menu, int menuResourceId, Activity activity, boolean disabled) {
  MenuItem item = menu.findItem(menuResourceId);
  if (item != null) {
    if (disabled) {
      item.setVisible(false);
    } else {
      MediaRouteButton button = new MediaRouteButton(activity);  // don't pass mContext, it needs a real activity or it's fucked
      button.setRouteSelector(mMediaRouteSelector);

      if (null != getMediaRouteDialogFactory()) {
        button.setDialogFactory(getMediaRouteDialogFactory());
      }

      item.setActionView(button);
    }
  }
}
 
开发者ID:sgehrman,项目名称:UTubeTV,代码行数:18,代码来源:BaseCastManager.java

示例3: onCreate

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
/**
 * Initializes MediaRouter information and prepares for Cast device detection upon creating
 * this activity.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    logVIfEnabled(TAG, "onCreate called");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cast_sample);

    mCastContext = new CastContext(getApplicationContext());
    mMedia = new CastMedia(null, null);
    mMetaData = new ContentMetadata();

    mDialogFactory = new SampleMediaRouteDialogFactory();

    MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
    mMediaRouter = MediaRouter.getInstance(getApplicationContext());
    mMediaRouteSelector = MediaRouteHelper
            .buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST);

    mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
    mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
    mMediaRouteButton.setDialogFactory(mDialogFactory);
    mMediaRouterCallback = new MyMediaRouterCallback();

    mStatusText = (TextView) findViewById(R.id.play_status_text);
    mCurrentlyPlaying = (TextView) findViewById(R.id.currently_playing);
    mCurrentlyPlaying.setText(getString(R.string.tap_to_select));
    mMediaSelectionDialog = new MediaSelectionDialog(this);

    mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
    mStopButton = (ImageButton) findViewById(R.id.stop_button);
    initButtons();

    Thread myThread = null;
    Runnable runnable = new StatusRunner();
    myThread = new Thread(runnable);
    logVIfEnabled(TAG, "Starting statusRunner thread");
    myThread.start();
}
 
开发者ID:Cameronjmayfield,项目名称:cast-android-sample,代码行数:42,代码来源:CastSampleActivity.java

示例4: onCreate

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
/**
 * Initializes MediaRouter information and prepares for Cast device detection upon creating
 * this activity.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    logVIfEnabled(TAG, "onCreate called");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cast_sample);

    mCastContext = new CastContext(getApplicationContext());
    mMedia = new CastMedia(null, null);
    mMetaData = new ContentMetadata();

    mDialogFactory = new SampleMediaRouteDialogFactory();

    MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
    mMediaRouter = MediaRouter.getInstance(getApplicationContext());
    mMediaRouteSelector = MediaRouteHelper
            .buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST,
                    getResources().getString(R.string.app_name), null);

    mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
    mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
    mMediaRouteButton.setDialogFactory(mDialogFactory);
    mMediaRouterCallback = new MyMediaRouterCallback();

    mStatusText = (TextView) findViewById(R.id.play_status_text);
    mCurrentlyPlaying = (TextView) findViewById(R.id.currently_playing);
    mCurrentlyPlaying.setText(getString(R.string.tap_to_select));
    mMediaSelectionDialog = new MediaSelectionDialog(this);

    mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
    mStopButton = (ImageButton) findViewById(R.id.stop_button);
    initButtons();

    Thread myThread = null;
    Runnable runnable = new StatusRunner();
    myThread = new Thread(runnable);
    logVIfEnabled(TAG, "Starting statusRunner thread");
    myThread.start();
}
 
开发者ID:johnjohndoe,项目名称:cast-android-sample-android-studio,代码行数:43,代码来源:CastSampleActivity.java

示例5: onCreateOptionsMenu

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
	DownloadService downloadService = getDownloadService();
	if(Util.isOffline(context)) {
		menuInflater.inflate(R.menu.nowplaying_offline, menu);
	} else {
		menuInflater.inflate(R.menu.nowplaying, menu);
	}
	if(downloadService != null && downloadService.getSleepTimer()) {
		int timeRemaining = downloadService.getSleepTimeRemaining();
		timerMenu = menu.findItem(R.id.menu_toggle_timer);
		if(timeRemaining > 1){
			timerMenu.setTitle(context.getResources().getString(R.string.download_stop_time_remaining, Util.formatDuration(timeRemaining)));
		} else {
			timerMenu.setTitle(R.string.menu_set_timer);
		}
	}
	if(downloadService != null && downloadService.getKeepScreenOn()) {
		menu.findItem(R.id.menu_screen_on_off).setChecked(true);
	}
	if(downloadService != null && downloadService.isRemovePlayed()) {
		menu.findItem(R.id.menu_remove_played).setChecked(true);
	}

	boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerAvailable();
	boolean isRemoteEnabled = downloadService != null && downloadService.isRemoteEnabled();
	if(equalizerAvailable && !isRemoteEnabled) {
		SharedPreferences prefs = Util.getPreferences(context);
		boolean equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false);
		if (equalizerOn && downloadService != null) {
			if(downloadService.getEqualizerController() != null && downloadService.getEqualizerController().isEnabled()) {
				menu.findItem(R.id.menu_equalizer).setChecked(true);
			}
		}
	} else {
		menu.removeItem(R.id.menu_equalizer);
	}

	if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M || isRemoteEnabled) {
		playbackSpeedButton.setVisibility(View.GONE);
	} else {
		playbackSpeedButton.setVisibility(View.VISIBLE);
	}

	if(downloadService != null) {
		MenuItem mediaRouteItem = menu.findItem(R.id.menu_mediaroute);
		if(mediaRouteItem != null) {
			MediaRouteButton mediaRouteButton = (MediaRouteButton) MenuItemCompat.getActionView(mediaRouteItem);
			mediaRouteButton.setDialogFactory(new CustomMediaRouteDialogFactory());
			mediaRouteButton.setRouteSelector(downloadService.getRemoteSelector());
		}

		if(downloadService.isCurrentPlayingSingle()) {
			if(!Util.isOffline(context)) {
				menu.removeItem(R.id.menu_save_playlist);
			}

			menu.removeItem(R.id.menu_batch_mode);
			menu.removeItem(R.id.menu_remove_played);
		}
	}

	if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_BATCH_MODE, false)) {
		menu.findItem(R.id.menu_batch_mode).setChecked(true);
	}
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:67,代码来源:NowPlayingFragment.java

示例6: onCreate

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
/**
 * Initializes MediaRouter information and prepares for Cast device
 * detection upon creating this activity.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    logVIfEnabled(TAG, "onCreate called");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cast);

    mCastContext = new CastContext(getApplicationContext());
    mMedia = new CastMedia(null, null);
    mMetaData = new ContentMetadata();

    mDialogFactory = new SampleMediaRouteDialogFactory();

    MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
    mMediaRouter = MediaRouter.getInstance(getApplicationContext());
    mMediaRouteSelector = MediaRouteHelper
            .buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST);

    mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
    mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
    mMediaRouteButton.setDialogFactory(mDialogFactory);
    mMediaRouterCallback = new MyMediaRouterCallback();

    mStatusText = (TextView) findViewById(R.id.play_status_text);
    mCurrentlyPlaying = (TextView) findViewById(R.id.currently_playing);
    mCurrentlyPlaying.setText(getString(R.string.tap_to_select));

    mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
    mStopButton = (ImageButton) findViewById(R.id.stop_button);
    initButtons();

    myThread = null;
    Runnable runnable = new StatusRunner();
    myThread = new Thread(runnable);
    logVIfEnabled(TAG, "Starting statusRunner thread");
    myThread.start();

    Intent intent = getIntent();
    String url = intent.getStringExtra("MEDIA_URL");
    urls = intent.getStringArrayListExtra("MEDIA_URL_LIST");
    if (urls == null || urls.size() == 0) {
        urls = new ArrayList<String>();
        urls.add(url);
    }
    title = intent.getStringExtra("MEDIA_TITLE");

    if (title == null || title.isEmpty())
        title = urls.get(0);

    this.mediaSelected(new CastMedia(title, urls.get(0)));
    nextUrl++;
}
 
开发者ID:qiushengxy,项目名称:cast-any,代码行数:56,代码来源:CastActivity.java

示例7: onCastAvailabilityChanged

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
/**
 * Adds and wires up the {@link android.support.v7.app.MediaRouteButton} instance that is passed
 * as an argument. This requires that
 * <ul>
 * <li>The enclosing {@link android.app.Activity} inherits (directly or indirectly) from
 * {@link android.support.v4.app.FragmentActivity}</li>
 * <li>User adds the {@link android.support.v7.app.MediaRouteButton} to the layout and passes a
 * reference to that instance to this method</li>
 * <li>User is in charge of controlling the visibility of this button. However, this library
 * makes it easier to do so: use the callback <code>onCastAvailabilityChanged(boolean)</code>
 * to change the visibility of the button in your client. For example, extend
 * {@link com.google.android.libraries.cast.companionlibrary.cast.callbacks.VideoCastConsumerImpl}
 * and override that method:
 *
 * <pre>
   public void onCastAvailabilityChanged(boolean castPresent) {
       mMediaRouteButton.setVisibility(castPresent ? View.VISIBLE : View.INVISIBLE);
   }
 * </pre>
 * </li>
 * </ul>
 */
public final void addMediaRouterButton(MediaRouteButton button) {
    button.setRouteSelector(mMediaRouteSelector);
    if (getMediaRouteDialogFactory() != null) {
        button.setDialogFactory(getMediaRouteDialogFactory());
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:29,代码来源:BaseCastManager.java

示例8: addMediaRouterButton

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
/**
 * Adds and wires up the {@link android.support.v7.app.MediaRouteButton} instance that is
 * passed as an argument. This requires that
 * <ul>
 * <li>The enclosing {@link android.app.Activity} inherits (directly or indirectly) from
 * {@link android.support.v4.app.FragmentActivity}</li>
 * <li>User adds the {@link android.support.v7.app.MediaRouteButton} to the layout and
 * pass a reference to that instance to this method</li>
 * <li>User is in charge of controlling the visibility of this button. However, this
 * library makes it easier to do so: use the callback
 * <code>onCastAvailabilityChanged(boolean)</code> to change the visibility of the button in
 * your client. For example, extend
 * {@link com.google.sample.castcompanionlibrary.cast.callbacks.VideoCastConsumerImpl}
 * and override that method:
 * <pre>
 * {@code
 * public void onCastAvailabilityChanged(boolean castPresent) {
 * mMediaRouteButton.setVisibility(castPresent ? View.VISIBLE : View.INVISIBLE);
 * }
 * }
 *     </pre>
 * </li>
 * </ul>
 */
public MediaRouteButton addMediaRouterButton(MediaRouteButton button) {
    button.setRouteSelector(mMediaRouteSelector);
    if (null != getMediaRouteDialogFactory()) {
        button.setDialogFactory(getMediaRouteDialogFactory());
    }
    return button;
}
 
开发者ID:BruGTUG,项目名称:codelab-chromecast,代码行数:32,代码来源:BaseCastManager.java

示例9: onCastAvailabilityChanged

import android.support.v7.app.MediaRouteButton; //导入方法依赖的package包/类
/**
     * Adds and wires up the {@link android.support.v7.app.MediaRouteButton} instance that is passed
     * as an argument. This requires that
     * <ul>
     *     <li>The enclosing {@link android.app.Activity} inherits (directly or indirectly) from
     *     {@link android.support.v4.app.FragmentActivity}</li>
     *     <li>User adds the {@link android.support.v7.app.MediaRouteButton} to the layout and
     *     pass a reference to that instance to this method</li>
     *     <li>User is in charge of controlling the visibility of this button. However, this
     *     library makes it easier to do so: use the callback
     *     <code>onCastAvailabilityChanged(boolean)</code> to change the visibility of the button in
     *     your client. For example, extend
     *     {@link com.google.sample.castcompanionlibrary.cast.callbacks.VideoCastConsumerImpl}
     *     and override that method:
     *     <pre>
{@code
public void onCastAvailabilityChanged(boolean castPresent) {
    mMediaRouteButton.setVisibility(castPresent ? View.VISIBLE : View.INVISIBLE);
}
    }
     *     </pre>
     *     </li>
     * </ul>
     * @param button
     * @return
     */
    public MediaRouteButton addMediaRouterButton(MediaRouteButton button) {
        button.setRouteSelector(mMediaRouteSelector);
        if (null != getMediaRouteDialogFactory()) {
            button.setDialogFactory(getMediaRouteDialogFactory());
        }
        return button;
    }
 
开发者ID:TByron,项目名称:Jupiter-Broadcasting-Holo,代码行数:34,代码来源:BaseCastManager.java


注:本文中的android.support.v7.app.MediaRouteButton.setRouteSelector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。