本文介绍了通过 A2DP/AVRCP 发送曲目信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 A2DP/AVRCP 发送曲目信息.现在,音乐是完美的流式传输,但在接收器"(即:汽车音响)上,曲目信息屏幕"是空白的(使用流行的播放器并非如此).有什么想法吗?

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 blank (which is not the case using popular players out there).Any idea ?

推荐答案

这段代码对我有用:

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);
}

根据您的播放状态以适当的意图(如上定义)调用 bluetoothNotifyChange:暂停/播放/元数据已更改.

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

这篇关于通过 A2DP/AVRCP 发送曲目信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 15:24