本文介绍了如何通过手机喇叭播放媒体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能使用的MediaPlayer播放媒体。

I'm able to play a media using a MediaPlayer.

但我怎么能播放媒体只用免提电话?我曾尝试:

But how can I play the media with speaker phone only? I have tried:

AudioManager audioManager = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE);
audioManager.setSpeakerphoneOn(true);

这是行不通的。我有这个添加到我的清单文件

That does not work. And I have add this to my Manifest file

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

有人能告诉我我在想什么?

Can someone please tell me what am i missing?

推荐答案

setSpeakerphoneOn()仅当音频模式设置为MODE_IN_CALL工作。试试这个:

setSpeakerphoneOn() only work when audio mode set to MODE_IN_CALL. Try this:

AudioManager audioManager =(AudioManager)mActivity.getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_IN_CALL);audioManager.setSpeakerphoneOn(真);

AudioManager audioManager = (AudioManager)mActivity.getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_IN_CALL);audioManager.setSpeakerphoneOn(true);

请记住设置恢复到正常模式下,你不干了。

Please remember set back to normal mode before you quit.

这篇关于如何通过手机喇叭播放媒体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 16:32