如何发挥或继续其他音乐播放器的音乐从我的code? [英] how to play or resume music of another music player from my code?

查看:152
本文介绍了如何发挥或继续其他音乐播放器的音乐从我的code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我想打或恢复播放的音乐后暂停它。 我有我的应用程序<一href="http://stackoverflow.com/questions/5129027/android-application-to-pause-resume-the-music-of-another-music-player-app">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";

来自: <一href="https://android.googlesource.com/platform/packages/apps/Music/+/master/src/com/android/music/MediaPlaybackService.java">https://android.googlesource.com/platform/packages/apps/Music/+/master/src/com/android/music/MediaPlaybackService.java

这篇关于如何发挥或继续其他音乐播放器的音乐从我的code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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