mac搜不到Android模拟器,听不到声音Android模拟器Mac

我无法在我的Mac的Android模拟器中听到任何声音。有时候,我真的很少听到它。我给你我的声音管理器代码。但我认为它的配置问题听不到声音Android模拟器Mac

我从他们说它的工作页面复制代码。而且我已经尝试过5种不同的代码并且没有任何作用。我的声音是WAV游戏:100K 800K菜单

感谢

import java.util.HashMap;

import android.content.Context;

import android.media.AudioManager;

import android.media.SoundPool;

public class SoundManager {

static private SoundManager _instance;

private static SoundPool mSoundPool;

private static HashMap mSoundPoolMap;

private static AudioManager mAudioManager;

private static Context mContext;

private SoundManager()

{

}

/**

* Requests the instance of the Sound Manager and creates it

* if it does not exist.

*

* @return Returns the single instance of the SoundManager

*/

static synchronized public SoundManager getInstance()

{

if (_instance == null)

_instance = new SoundManager();

return _instance;

}

/**

* Initialises the storage for the sounds

*

* @param theContext The Application context

*/

public static void initSounds(Context theContext)

{

mContext = theContext;

mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);

mSoundPoolMap = new HashMap();

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

}

/**

* Add a new Sound to the SoundPool

*

* @param Index - The Sound Index for Retrieval

* @param SoundID - The Android ID for the Sound asset.

*/

public static void addSound(int Index,int SoundID)

{

mSoundPoolMap.put(Index, mSoundPool.load(mContext, SoundID, 1));

}

/**

* Loads the various sound assets

* Currently hard coded but could easily be changed to be flexible.

*/

public static void loadSounds()

{

mSoundPoolMap.put(1, mSoundPool.load(mContext, R.raw.menu, 1));

mSoundPoolMap.put(2, mSoundPool.load(mContext, R.raw.game, 1));

}

/**

* Plays a Sound

*

* @param index - The Index of the Sound to be played

* @param speed - The Speed to play not, not currently used but included for compatibility

*/

public static void playSound(int index,float speed)

{

float streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);

streamVolume = streamVolume/mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, speed);

}

/**

* Stop a Sound

* @param index - index of the sound to be stopped

*/

public static void stopSound(int index)

{

mSoundPool.stop(mSoundPoolMap.get(index));

}

public static void cleanup()

{

mSoundPool.release();

mSoundPool = null;

mSoundPoolMap.clear();

mAudioManager.unloadSoundEffects();

_instance = null;

}

}

2011-11-18

Edig

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值