媒体播放器上的低音量水平 - Android Things



我在Android Things上有一个相当模糊的问题,音频输出水平低。 我的硬件设置是RPI 3(Raspberry(,运行Google IoT RPI3 ver 1.0.2,音频输出槽耳机插孔。

这是我从互联网上下载的简单音频文件。我将其导入到项目的原始文件夹中。并试图逃跑。

这是我的简单代码,以便您可以重现:

package com.mystuff.lowvolumeissue;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.sampleaudio);
mediaPlayer.setVolume(1,1);
mediaPlayer.start(); // no need to call prepare(); create() does that for you
}
}

只是为了确保一切设置正确,这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mystuff.lowvolumeissue">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application>
<uses-library android:name="com.google.android.things" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.IOT_LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

当我听到输出槽式耳机时,当我在 PC 槽式耳机上播放相同的样本时,声音水平仅为输出的 50%。

有人在这里提出了类似的问题。

任何建议如何解决这个问题?

是的,通过音频管理器设置音量解决了问题。 多谢

更新: 代码

AudioManager mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);

最新更新