通过三星的默认媒体播放器使用媒体按钮广播
我使用 Intent.ACTION_MEDIA_BUTTON 构建了一个应用程序来控制当前的媒体播放,但一位客户报告该应用程序无法与他们的三星音乐播放器配合使用。有谁知道三星媒体播放器是否不支持媒体按钮,如果是,如何修复?
I built an app using Intent.ACTION_MEDIA_BUTTON to control the current media play, but a customer reported it wasn't working with their Samsung music player. Does anyone know if the Samsung media player doesn't support media buttons, and if so how to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有适合您的解决方案,但我可以确认我的 Samsung Galaxy S / Android 2.1 测试设备上的库存媒体播放器不响应“切换播放/暂停”(KEYCODE_MEDIA_PLAY_PAUSE) 或“下一曲目”(KEYCODE_MEDIA_NEXT) ),所以可以肯定的是它也不会响应其他的。
如果您使用 logcat 来跟踪使用内置耳机使用内联开关/麦克风“切换播放/暂停”时发生的情况,您可以看到它发送 KEYCODE_HEADSETHOOK,您可以在代码中发送它,并且至少会“切换播放/暂停” ' 在股票媒体播放器上。
但仅此而已。确实有点垃圾。干得好,三星!
编辑:经过更多的挖掘,我得到了以下与三星媒体播放器一起使用的信息:
并且:
我非常有兴趣知道它的普遍适用性 - 对我来说似乎有点脆弱......
最后,沿着同样的路线我发现(将 musicIntent.setAction() 行替换为):
这不适用于三星播放器,但可能对某人有用......
I don't have a solution for you, but I can confirm that the stock media player on my Samsung Galaxy S / Android 2.1 testing unit does not respond to either 'toggle play/pause' (KEYCODE_MEDIA_PLAY_PAUSE) or 'next track' (KEYCODE_MEDIA_NEXT), so it's a fair bet that it won't respond to others either.
If you use logcat to follow what happens when you use the stock headset to 'toggle play/pause' using the inline switch/mic, you can see it sending KEYCODE_HEADSETHOOK, which you can send in code and will at least 'toggle play/pause' on the stock media player.
But that's it. Bit rubbish, really. Good on ya, Samsung!
EDIT: After a bit more digging I got the following to work with the Samsung Media Player:
and:
I would be very interested to know how generally applicable this is - seems a bit fragile to me...
And lastly, along the same lines I found (replace the musicIntent.setAction() line with):
This did not work with the Samsung player, but might be of use to someone...