Control de reproductor de música en notificación

¡Cómo configurar la notificación con reproducción / pausa, botón siguiente y anterior en Android!

Soy nuevo con Android y también en el desbordamiento de pila. Así que por favor tengan paciencia conmigo.

Establezco una notificación cuando la canción comienza a reproducirse como se muestra a continuación:

`

@SuppressLint("NewApi")
public void setNotification(String songName){
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager notificationManager = (NotificationManager) getSystemService(ns);


    @SuppressWarnings("deprecation")
    Notification notification = new Notification(R.drawable.god_img, null, System.currentTimeMillis());

    RemoteViews notificationView = new RemoteViews(getPackageName(), R.layout.notification_mediacontroller);

    //the intent that is started when the notification is clicked (works)
    Intent notificationIntent = new Intent(this, AudioBookListActivity.class);
    PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.contentView = notificationView;
    notification.contentIntent = pendingNotificationIntent;
    notification.flags |= Notification.FLAG_NO_CLEAR;

    //this is the intent that is supposed to be called when the button is clicked
    Intent switchIntent = new Intent(this, AudioPlayerBroadcastReceiver.class);
    PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0, switchIntent, 0);

    notificationView.setOnClickPendingIntent(R.id.btn_play_pause_in_notification, pendingSwitchIntent);
    notificationManager.notify(1, notification);        
}

`

He creado BroadcastReceiver como a continuación: `

   private class AudioPlayerBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        System.out.println("intent action = " + action);
        long id = intent.getLongExtra("id", -1);

        if(Constant.PLAY_ALBUM.equals(action)) {
            //playAlbum(id);
        } else if(Constant.QUEUE_ALBUM.equals(action)) {
            //queueAlbum(id);
        } else if(Constant.PLAY_TRACK.equals(action)) {
            //playTrack(id);
        } else if(Constant.QUEUE_TRACK.equals(action)) {
            //queueTrack(id);
        } else if(Constant.PLAY_PAUSE_TRACK.equals(action)) {
 //                playPauseTrack();
            System.out.println("press play");
        } else if(Constant.HIDE_PLAYER.equals(action)) {
 //                hideNotification();
            System.out.println("press next");
        }
        else {
        }
    }

}`

Ahora, configuré la notificación personalizada con éxito, pero ¿cómo puedo manejar los botones de notificación y sus eventos como reproducir / pausar, anterior y siguiente ... etc. También trato de usar el receptor de transmisión pero no pude obtener ninguna respuesta.

Buscando solución y orientación de expertos, por favor ayúdenme.

Gracias por adelantado.

Respuestas a la pregunta(1)

Su respuesta a la pregunta