7
Devam etmekte olan oynatma bildirimimizi Lollipop'te tanıtılan MediaStyle bildirimlerine geçirme sürecindeyiz. RemoteControlClient kullanımdan kaldırılmış gibi görünüyor ve MediaStyle bildirimi medya düğmesi olaylarını (uzaktan kumanda ile duraklatma/oynatma gibi) işlemiyor.MediaStyle bildirimi, RemoteControl olaylarına yanıt vermiyor.
Bu işi yapan var mı? MediaSessionCallback'teki olaylardan hiçbiri çağrılmıyor. çalma devlet Set
MediaSession mediaSession = (MediaSession) session.getMediaSession();
Notification.Builder builder =
new Notification.Builder(c)
.setDefaults(0)
.setSmallIcon(R.drawable.ic_notif)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(clip.getTitle())
.setContentText(clip.getSourceName())
.setProgress((int)duration, (int)progress, false)
.setWhen(0)
.setContentIntent(pendingIntent);
if (playing) {
builder.addAction(R.drawable.ic_media_pause, c.getString(R.string.media_pause),
getPendingIntentForKeyCode(app.getApplicationContext(), KeyEvent.KEYCODE_MEDIA_PAUSE));
} else {
builder.addAction(R.drawable.ic_media_play, c.getString(R.string.media_play),
getPendingIntentForKeyCode(app.getApplicationContext(), KeyEvent.KEYCODE_MEDIA_PLAY));
}
builder.addAction(R.drawable.ic_media_next, c.getString(R.string.media_next),
getPendingIntentForKeyCode(app.getApplicationContext(), KeyEvent.KEYCODE_MEDIA_NEXT));
builder.setStyle(new Notification.MediaStyle()
.setMediaSession(mediaSession.getSessionToken())
.setShowActionsInCompactView(new int[] {1, 2})
)
);
notification = builder.build();
Uyumluluk kütüphanesi için şu gibi bir şey olmalıdır: PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder(); stateBuilder.setActions (PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS); stateBuilder.setState (PlaybackState.STATE_PLAYING, 0, 1); m_objMediaSession.setPlaybackState (stateBuilder.build()); – goRGon
^hafif düzeltme, 'PlaybackStateCompat.ACTION_PLAY' vb. – hypd09