如何发挥或继续其他音乐播放器的音乐从我的code?我的、播放器、音乐、继续

由网友(高傲抬头、视你不见℡)分享简介:在我的Andr​​oid应用程序,我想打或恢复播放的音乐后暂停它。我有我的应用程序pause音乐通过发送一个广播,但我不能让它发挥或恢复音乐。In my android app I want to play or resume the played music after a paused it.I got my...

在我的Andr​​oid应用程序,我想打或恢复播放的音乐后暂停它。 我有我的应用程序pause音乐通过发送一个广播,但我不能让它发挥或恢复音乐。

In my android app I want to play or resume the played music after a paused it. I got my app to pause the music by sending a broadcast, but I can't get it to play or resume the music.

这里是code暂停

    Intent i = new Intent("com.android.music.musicservicecommand");
            i.putExtra("command", "pause");
            sendBroadcast(i);

如何能不能做到?

how can it be done?

编辑:对不起,我写的简历,而不是暂停

sorry, I wrote "resume" instead of "pause"

推荐答案

这个问题是旧的。以下是我已经发现了这些测试之后。

This question is old. Here is what I have discovered after testing these.

我曾尝试和验证这些命令的工作就好了。

I have tried and verified these commands to work just fine.

// pause
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "pause");
sendBroadcast(i);

// play
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "play");
sendBroadcast(i);

// next
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "next");
sendBroadcast(i);

// previous
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "previous");
sendBroadcast(i);

有关可用命令的一些详细信息:

Some more info about available commands:

public static final String SERVICECMD = "com.android.music.musicservicecommand";
public static final String CMDNAME = "command";
public static final String CMDTOGGLEPAUSE = "togglepause";
public static final String CMDSTOP = "stop";
public static final String CMDPAUSE = "pause";
public static final String CMDPLAY = "play";
public static final String CMDPREVIOUS = "previous";
public static final String CMDNEXT = "next";

来自: https://android.googlesource.com/platform/packages/apps/Music/+/master/src/com/android/music/MediaPlaybackService.java

阅读全文

相关推荐

最新文章