我的Android应用程序上有一个RemoteControlClient,并为其提供了以下标志:
myRemoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY |
RemoteControlClient.FLAG_KEY_MEDIA_PAUSE |
RemoteControlClient.FLAG_KEY_MEDIA_REWIND |
RemoteControlClient.FLAG_KEY_MEDIA_FAST_FORWARD |
RemoteControlClient.FLAG_KEY_MEDIA_STOP);
但是,当它在锁定屏幕上显示时,我只能看到暂停或播放,具体取决于我是在播放还是在暂停。
没有办法显示其他控件吗?
谢谢。
编辑:这是我的其余代码:
ComponentName myEventReceiver = new ComponentName(getApplicationContext().getPackageName(), PlayingBroadcastReceiver.class.getName());
myAudioManager =
(AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
myAudioManager.registerMediaButtonEventReceiver(myEventReceiver);
// build the PendingIntent for the remote control client
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(myEventReceiver);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
// create and register the remote control client
myRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
myRemoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY |
RemoteControlClient.FLAG_KEY_MEDIA_PAUSE |
RemoteControlClient.FLAG_KEY_MEDIA_REWIND | RemoteControlClient.FLAG_KEY_MEDIA_FAST_FORWARD |
RemoteControlClient.FLAG_KEY_MEDIA_STOP);
myAudioManager.registerRemoteControlClient(myRemoteControlClient);
myRemoteControlClient.editMetadata(true)
.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, item.getTitle())
.putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, item.getBitmap())
.apply();
setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
//Request audio focus for playback
int result = myAudioManager.requestAudioFocus(this,
AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN);
FLAG_KEY_MEDIA_STOP从未显示由于Android中的错误而停止,如此处报告的那样:https : //code.google.com/p/android/issues/detail? id=29920
我不确定是不是支持库(您在使用它吗?)是否导致fast_forward和rewind无法正常工作。我也无法显示它们,所以我改用下一个和上一个。我也可能不是在锁屏上看不到它们,而是可以通过实现它们的耳机和其他遥控器使用它们。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句