Dmi*_*try 6 media android bluetooth exoplayer
我已经制作了android音频应用程序.现在有些用户报告说,当他们通过汽车蓝牙连接设备时,应用程序没有响应媒体按钮(播放,暂停,下一个).
与此同时,我用蓝牙扬声器测试了应用程序 - 播放/暂停按钮可以根据需要工作.
车内蓝牙音箱和蓝牙收音机有什么区别吗??? 这很奇怪
我正在使用ExoPlayer并使用此代码处理媒体按钮:
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null, getApplicationContext(), MediaButtonReceiver.class);
mSession.setMediaButtonReceiver(PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0));
MediaSessionConnector mediaSessionConnector = new MediaSessionConnector(mSession, new DefaultPlaybackController(), false, null);
mediaSessionConnector.setQueueNavigator(new QueueNavigatorAdapter() {
@Override
public void onSkipToPrevious(Player player) {
playPrevious();
}
@Override
public void onSkipToNext(Player player) {
playNext();
}
});
mediaSessionConnector.setPlayer(mPlayer, null);
Run Code Online (Sandbox Code Playgroud)
和
mPlayer.prepare(source);
mSession.setActive(true);
mPlayer.setPlayWhenReady(true);
Run Code Online (Sandbox Code Playgroud)
我知道AudioManager.registerMediaButtonEventReceiver()和处理KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE等但我确信mSession.setMediaButtonReceiver && MediaSessionConnector为我做了.
也许我错了,这还不够?
minSdkVersion 21
我记得,你需要执行这样的操作:
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode()==25)
Run Code Online (Sandbox Code Playgroud)
基于您正在使用的蓝牙设备,在本例中为汽车中的蓝牙无线电。您需要汽车收音机设备的手册。
| 归档时间: |
|
| 查看次数: |
377 次 |
| 最近记录: |