Android应用程序可暂停/恢复的其他音乐播放器应用程序的音乐 [英] Android application to Pause/Resume the music of another music player app

查看:538
本文介绍了Android应用程序可暂停/恢复的其他音乐播放器应用程序的音乐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我玩用的MediaPlayer类不同的MP3文件。

In my Android application, I am playing different mp3 files using the MediaPlayer class.

该用户正在播放的他/她自己的音乐与默认的音乐应用程序。

The user is playing his/her own music with the default music application.

我想:

  1. 暂停默认的音乐应用程序的音乐。
  2. 开始从我的应用程序播放音乐。
  3. 如果我的音乐是做打,我的应用程序将恢复用户的默认音乐。

我想停下来,从我的应用程序恢复默认的音乐播放器的音乐。

I want to pause and resume the music of the default music player from my application.

是否有可能这样做吗?

推荐答案

以下code将暂停一个默认的MediaPlayer通过发送一个广播:

The following code will pause a default MediaPlayer by sending a broadcast:

AudioManager mAudioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);    

if (mAudioManager.isMusicActive()) {

    Intent i = new Intent("com.android.music.musicservicecommand");

    i.putExtra("command", "pause");
    YourApplicationClass.this.sendBroadcast(i);
} 

这篇关于Android应用程序可暂停/恢复的其他音乐播放器应用程序的音乐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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