send track informations via A2DP/AVRCP

前端 未结 5 879
北海茫月
北海茫月 2020-12-04 11:46

I\'m trying to send track informations via A2DP/AVRCP. Right now, music is perfectly streamed, but on the \"receiver\" (ie: car audio), the \"track informations screen\" is

5条回答
  •  渐次进展
    2020-12-04 12:10

    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.

提交回复
热议问题