本文整理匯總了Java中android.media.RemoteControlClient.setTransportControlFlags方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteControlClient.setTransportControlFlags方法的具體用法?Java RemoteControlClient.setTransportControlFlags怎麽用?Java RemoteControlClient.setTransportControlFlags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.RemoteControlClient
的用法示例。
在下文中一共展示了RemoteControlClient.setTransportControlFlags方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerRemoteControl
import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void registerRemoteControl(ComponentName rcvMedia) {
mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(rcvMedia);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
0, mediaButtonIntent, 0);
remoteControlClient = new RemoteControlClient(mediaPendingIntent);
remoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
);
mAudioManager.registerRemoteControlClient(remoteControlClient);
}
示例2: if
import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void registrér() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) return;
App.audioManager.registerMediaButtonEventReceiver(fjernbetjeningReciever);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) return;
// 'det er irriterende at den ændre billedet på lock - screen, det skal være muligt at disable dette.'
if (!App.prefs.getBoolean("fjernbetjening", true)) return;
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON).setComponent(fjernbetjeningReciever);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(ApplicationSingleton.instans, 0, mediaButtonIntent, 0);
// create and register the remote control client
remoteControlClient = new RemoteControlClient(mediaPendingIntent);
remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
| RemoteControlClient.FLAG_KEY_MEDIA_NEXT
| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
| RemoteControlClient.FLAG_KEY_MEDIA_STOP
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY
);
App.audioManager.registerRemoteControlClient(remoteControlClient);
}
示例3: registerRemoteControlClient
import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void registerRemoteControlClient(ComponentName componentName) {
audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
Intent remoteControlIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
remoteControlIntent.setComponent(componentName);
RemoteControlClient localRemoteControlClient = new RemoteControlClient(
PendingIntent.getBroadcast(context, 0, remoteControlIntent, 0));
localRemoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
| RemoteControlClient.FLAG_KEY_MEDIA_NEXT
| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY
| RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
);
audioManager.registerRemoteControlClient(localRemoteControlClient);
this.remoteControlClient = localRemoteControlClient;
}
示例4: registerRemote
import android.media.RemoteControlClient; //導入方法依賴的package包/類
/**
* Perform initialization required for RemoteControlClient.
*
* @param context A context to use.
* @param am The AudioManager service.
*/
public static void registerRemote(Context context, AudioManager am)
{
if (!MediaButtonReceiver.useHeadsetControls(context)) {
// RemoteControlClient requires MEDIA_BUTTON intent
return;
}
MediaButtonReceiver.registerMediaButton(context);
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(new ComponentName(context.getPackageName(), MediaButtonReceiver.class.getName()));
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0, mediaButtonIntent, 0);
RemoteControlClient remote = new RemoteControlClient(mediaPendingIntent);
int flags = RemoteControlClient.FLAG_KEY_MEDIA_NEXT
| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY
| RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
remote.setTransportControlFlags(flags);
am.registerRemoteControlClient(remote);
sRemote = remote;
}
示例5: changeRemoteControlClient
import android.media.RemoteControlClient; //導入方法依賴的package包/類
/**
* Set up the remote control and tell the system we want to be the default receiver for the MEDIA buttons
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void changeRemoteControlClient(AudioManager am, boolean acquire) {
if (acquire) {
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(mRemoteControlClientReceiverComponent);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0);
// create and register the remote control client
mRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
am.registerRemoteControlClient(mRemoteControlClient);
mRemoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY |
RemoteControlClient.FLAG_KEY_MEDIA_PAUSE |
RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS |
RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
RemoteControlClient.FLAG_KEY_MEDIA_STOP);
} else {
am.unregisterRemoteControlClient(mRemoteControlClient);
mRemoteControlClient = null;
}
}
示例6: register
import android.media.RemoteControlClient; //導入方法依賴的package包/類
public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
downloadService = (DownloadService) context;
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// build the PendingIntent for the remote control client
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(mediaButtonReceiverComponent);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);
// create and register the remote control client
mRemoteControl = new RemoteControlClient(mediaPendingIntent);
audioManager.registerRemoteControlClient(mRemoteControl);
mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
mRemoteControl.setTransportControlFlags(getTransportFlags());
imageLoader = SubsonicActivity.getStaticImageLoader(context);
}
示例7: register
import android.media.RemoteControlClient; //導入方法依賴的package包/類
public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
downloadService = (DownloadService) context;
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// build the PendingIntent for the remote control client
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(mediaButtonReceiverComponent);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);
// create and register the remote control client
mRemoteControl = new RemoteControlClient(mediaPendingIntent);
audioManager.registerRemoteControlClient(mRemoteControl);
mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
mRemoteControl.setTransportControlFlags(getTransportFlags());
imageLoader = SubsonicTabActivity.getStaticImageLoader(context);
}
示例8: setupRemoteControlClient
import android.media.RemoteControlClient; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private RemoteControlClient setupRemoteControlClient() {
if (Build.VERSION.SDK_INT < 14) {
return null;
}
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(new ComponentName(getPackageName(),
MediaButtonReceiver.class.getName()));
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(
getApplicationContext(), 0, mediaButtonIntent, 0);
remoteControlClient = new RemoteControlClient(mediaPendingIntent);
int controlFlags;
if (android.os.Build.VERSION.SDK_INT < 16) {
controlFlags = RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
| RemoteControlClient.FLAG_KEY_MEDIA_NEXT;
} else {
controlFlags = RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE;
}
remoteControlClient.setTransportControlFlags(controlFlags);
return remoteControlClient;
}
示例9: registerRCC
import android.media.RemoteControlClient; //導入方法依賴的package包/類
private void registerRCC() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// Create the RCC and register with AudioManager and MediaRouter
mAudioManager.requestAudioFocus(mAfChangeListener,
AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
mAudioManager.registerMediaButtonEventReceiver(mEventReceiver);
mRemoteControlClient = new RemoteControlClient(mMediaPendingIntent);
mAudioManager.registerRemoteControlClient(mRemoteControlClient);
mMediaRouter.addRemoteControlClient(mRemoteControlClient);
SampleMediaButtonReceiver.setActivity(SampleMediaRouterActivity.this);
mRemoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE);
mRemoteControlClient.setPlaybackState(
RemoteControlClient.PLAYSTATE_PLAYING);
}
}
示例10: registerRemoteControl
import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void registerRemoteControl(ComponentName rcvMedia) {
mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN);
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(rcvMedia);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
0, mediaButtonIntent, 0);
remoteControlClient = new RemoteControlClient(mediaPendingIntent);
remoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
);
mAudioManager.registerRemoteControlClient(remoteControlClient);
}
示例11: registerRemote
import android.media.RemoteControlClient; //導入方法依賴的package包/類
public static void registerRemote(Context context, AudioManager am) {
MediaButtonReceiver.registerMediaButton(context);
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(new ComponentName(context.getPackageName(),
MediaButtonReceiver.class.getName()));
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0,
mediaButtonIntent, 0);
RemoteControlClient remote = new RemoteControlClient(mediaPendingIntent);
int flags = RemoteControlClient.FLAG_KEY_MEDIA_NEXT
| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
| RemoteControlClient.FLAG_KEY_MEDIA_PLAY
| RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
remote.setTransportControlFlags(flags);
am.registerRemoteControlClient(remote);
sRemote = remote;
}
示例12: RemoteControlClientBroadcaster
import android.media.RemoteControlClient; //導入方法依賴的package包/類
public RemoteControlClientBroadcaster(Context context, CachedFilePropertiesProvider cachedFilePropertiesProvider, ImageProvider imageProvider, RemoteControlClient remoteControlClient) {
this.context = context;
this.cachedFilePropertiesProvider = cachedFilePropertiesProvider;
this.imageProvider = imageProvider;
this.remoteControlClient = remoteControlClient;
remoteControlClient.setTransportControlFlags(standardControlFlags);
}
示例13: setupRemoteControlClient
import android.media.RemoteControlClient; //導入方法依賴的package包/類
private void setupRemoteControlClient() {
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
this.mediaButtonEventReceiver = new ComponentName(getPackageName(), MediaButtonReceiver.class.getName());
mediaButtonIntent.setComponent(mediaButtonEventReceiver);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
remoteControlClient = new RemoteControlClient(mediaPendingIntent);
remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE);
audioManager.registerMediaButtonEventReceiver(mediaButtonEventReceiver);
audioManager.registerRemoteControlClient(remoteControlClient);
}
示例14: setup
import android.media.RemoteControlClient; //導入方法依賴的package包/類
@Override
void setup() {
mAudioManager = (AudioManager) mService.getSystemService(Context.AUDIO_SERVICE);
mMediaButtonReceiverComponent = new ComponentName(mService.getPackageName(),
MediaButtonIntentReceiver.class.getName());
mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent);
final Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON)
.setComponent(mMediaButtonReceiverComponent);
mRemoteControlClient = new RemoteControlClient(
PendingIntent.getBroadcast(mService.getApplicationContext(), 0, mediaButtonIntent,
PendingIntent.FLAG_UPDATE_CURRENT));
mAudioManager.registerRemoteControlClient(mRemoteControlClient);
mRemoteControlClient.setTransportControlFlags(getFlags());
}
示例15: setUpRemoteControlClient
import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setUpRemoteControlClient() {
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
// Very important to request for the focus.
audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
// Set up the RemoteControlClient to invoke our BroadcastReceiver.
ComponentName eventReceiver = new ComponentName(this,
RemoteControlReceiver.class.getName());
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(eventReceiver);
PendingIntent mediaPendingIntent = PendingIntent.
getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
mRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
// Register the remote control client.
audioManager.registerMediaButtonEventReceiver(eventReceiver);
audioManager.registerRemoteControlClient(mRemoteControlClient);
// Add buttons that are needed on the remote control client.
mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
mRemoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
| RemoteControlClient.FLAG_KEY_MEDIA_NEXT
| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS);
mMediaRouter.addRemoteControlClient(mRemoteControlClient);
}