在三星的默认媒体播放器上使用媒体按钮广播 [英] Using Media Button Broadcasts with Samsung's default media player

查看:92
本文介绍了在三星的默认媒体播放器上使用媒体按钮广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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?

推荐答案

我没有适合您的解决方案,但我可以确认我的Samsung Galaxy S/Android 2.1测试装置上的库存媒体播放器没有响应切换播放/暂停"(KEYCODE_MEDIA_PLAY_PAUSE)或下一首曲目"(KEYCODE_MEDIA_NEXT),因此可以肯定的是,它也不会响应其他人.

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.

如果您使用logcat来跟踪当您使用嵌入式耳机通过嵌入式开关/麦克风切换播放/暂停"时发生的情况,您会看到它发送了KEYCODE_HEADSETHOOK,您可以发送该代码,并且至少会切换"在股票媒体播放器上播放/暂停".

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!

经过进一步的挖掘,我得到了以下与Samsung Media Player一起使用的功能:

After a bit more digging I got the following to work with the Samsung Media Player:

Intent musicIntent = new Intent();
musicIntent.setAction("com.sec.android.app.music.musicservicecommand.togglepause");
sendBroadcast(musicIntent);

和:

Intent musicIntent = new Intent();
musicIntent.setAction("com.sec.android.app.music.musicservicecommand.next");
sendBroadcast(musicIntent);

我很想知道这在多大程度上适用-对我来说似乎有点脆弱...

I would be very interested to know how generally applicable this is - seems a bit fragile to me...

最后,按照我发现的相同内容(将musicIntent.setAction()替换为):

And lastly, along the same lines I found (replace the musicIntent.setAction() line with):

musicIntent.setAction("com.android.music.musicservicecommand.next");
musicIntent.putExtra("command", "next"); // or "next" or "previous"

这不适用于Samsung播放器,但可能对某人有用...

This did not work with the Samsung player, but might be of use to someone...

这篇关于在三星的默认媒体播放器上使用媒体按钮广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆