androidbluetootha2dpavrcp

send track information via A2DP/AVRCP


I'm trying to send track information via A2DP/AVRCP. Right now, music is perfectly streamed, but on the "receiver" (ie: car audio), the "track information screen" is blank (which is not the case using popular players out there). Any idea ?


Solution

  • This code worked for me:

    private static final String AVRCP_PLAYSTATE_CHANGED = "com.android.music.playstatechanged";
    private static final String AVRCP_META_CHANGED = "com.android.music.metachanged";
    
    private void bluetoothNotifyChange(String what) {
        Intent i = new Intent(what);
        i.putExtra("id", Long.valueOf(getAudioId()));
        i.putExtra("artist", getArtistName());
        i.putExtra("album",getAlbumName());
        i.putExtra("track", getTrackName());
        i.putExtra("playing", isPlaying());        
        i.putExtra("ListSize", getQueue());
        i.putExtra("duration", duration());
        i.putExtra("position", position());
        sendBroadcast(i);
    }
    

    Call bluetoothNotifyChange with the appropriate intent (defined above) depending on your playback status: pause/playing/metadata changed.