本文整理汇总了Java中android.support.v7.app.MediaRouteButton.setDialogFactory方法的典型用法代码示例。如果您正苦于以下问题:Java MediaRouteButton.setDialogFactory方法的具体用法?Java MediaRouteButton.setDialogFactory怎么用?Java MediaRouteButton.setDialogFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.MediaRouteButton
的用法示例。
在下文中一共展示了MediaRouteButton.setDialogFactory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: 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();
}
示例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,
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();
}
示例4: 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);
}
}
示例5: 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++;
}
示例6: 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());
}
}
示例7: 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;
}
示例8: 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;
}