[6.2.4] fix bug of sound play helper , devices extends lenovo , npl of map init

This commit is contained in:
zhongchao
2023-12-18 12:01:23 +08:00
parent fbf4a89f37
commit 4c5b88aecf
7 changed files with 44 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.media.*;
import android.content.*;
import android.app.*;
import android.util.Log;
public class SoundPoolHelper {
private SoundPool mSoundPool;
@@ -38,7 +39,9 @@ public class SoundPoolHelper {
//init settings
private void init(){
// AudioManager audio settings for adjusting the volume
mAudioManager = (AudioManager)this.mContext. getSystemService(Context.AUDIO_SERVICE);
if(mAudioManager == null){
mAudioManager = (AudioManager)this.mContext. getSystemService(Context.AUDIO_SERVICE);
}
// Current volumn Index of particular stream type.
float currentVolumeIndex = (float) mAudioManager.getStreamVolume(streamType);
@@ -87,6 +90,10 @@ public class SoundPoolHelper {
//play the sound res
private void playSound(){
if(mSoundPool == null){
Log.e("SoundPoolHelper","playSound mSoundPool is null");
return;
}
float leftVolume = volume;
float rightVolume = volume;
// Play sound of gunfire. Returns the ID of the new stream.