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

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

问题描述

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

推荐答案

我没有给你一个解决方案,但我可以证实,我的三星Galaxy S / Android 2.1的检测单位对该股的媒体播放器不回应无论是切换播放/暂停(KEY code_MEDIA_PLAY_PAUSE)或下一首曲目(KEY code_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跟随当您使用的股票耳机切换播放/暂停使用内联开关/麦克风会发生什么,你可以看到它发送键code_HEADSETHOOK,您可以在$ C $发送c和至少会'切换播放/暂停对该股的媒体播放器。

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!

编辑:多一点挖后,我得到了以下与三星媒体播放器的工作:

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"

这并没有与三星的球员工作,但可能是使用的人...

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

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

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