本文整理汇总了Java中android.media.RemoteControlClient.setPlaybackState方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteControlClient.setPlaybackState方法的具体用法?Java RemoteControlClient.setPlaybackState怎么用?Java RemoteControlClient.setPlaybackState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.RemoteControlClient
的用法示例。
在下文中一共展示了RemoteControlClient.setPlaybackState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateRemote
import android.media.RemoteControlClient; //导入方法依赖的package包/类
/**
* Update the remote with new metadata.
* {@link #registerRemote(Context, AudioManager)} must have been called
* first.
*
* @param context A context to use.
* @param song The song containing the new metadata.
* @param state PlaybackService state, used to determine playback state.
*/
public static void updateRemote(Context context, Song song, int state)
{
RemoteControlClient remote = sRemote;
if (remote == null)
return;
remote.setPlaybackState((state & PlaybackService.FLAG_PLAYING) != 0 ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
RemoteControlClient.MetadataEditor editor = remote.editMetadata(true);
if (song != null) {
editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, song.artist);
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, song.album);
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, song.title);
Bitmap bitmap = song.getCover(context);
if (bitmap != null) {
// Create a copy of the cover art, since RemoteControlClient likes
// to recycle what we give it.
bitmap = bitmap.copy(Bitmap.Config.RGB_565, false);
}
editor.putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, bitmap);
}
editor.apply();
}
示例2: a
import android.media.RemoteControlClient; //导入方法依赖的package包/类
public void a(boolean flag, long l1, int i1)
{
if (m != null)
{
RemoteControlClient remotecontrolclient = m;
byte byte0;
float f1;
if (flag)
{
byte0 = 3;
} else
{
byte0 = 1;
}
if (flag)
{
f1 = 1.0F;
} else
{
f1 = 0.0F;
}
remotecontrolclient.setPlaybackState(byte0, l1, f1);
m.setTransportControlFlags(i1);
}
}
示例3: 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);
}
示例4: refreshState
import android.media.RemoteControlClient; //导入方法依赖的package包/类
public void refreshState(boolean flag, long l, int i)
{
if (mRemoteControl != null)
{
RemoteControlClient remotecontrolclient = mRemoteControl;
float f;
byte byte0;
if (flag)
{
byte0 = 3;
} else
{
byte0 = 1;
}
if (flag)
{
f = 1.0F;
} else
{
f = 0.0F;
}
remotecontrolclient.setPlaybackState(byte0, l, f);
mRemoteControl.setTransportControlFlags(i);
}
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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);
}
示例8: setMetaData
import android.media.RemoteControlClient; //导入方法依赖的package包/类
@TargetApi(19)
private void setMetaData() {
RemoteControlClient localRemoteControlClient = (RemoteControlClient) this.remoteControlClient;
RemoteControlClient.MetadataEditor editor = localRemoteControlClient.editMetadata(true);
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, authorField.getText().toString());
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, bookTitle);
editor.apply();
//Set cover too?
localRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
LOG.debug("Focus: updated meta-data");
}