大佬教程收集整理的这篇文章主要介绍了android – Soundpool和三星Galaxy S的问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当应用程序运行时,它启动Soundpool,如下所示,
public static final int SOUND_EXPLOSION = 1; public static final int SOUND_CLEAR = 2; public static final int SOUND_CLICK = 3; public static final int SOUND_MAGIC = 4; public static final int SOUND_ROCKET = 5; public static final int SOUND_MELT = 6; private SoundPool soundPool; private Au@L_161_8@manager mgr; private HashMap<Integer,Integer> soundPoolMap; private void initSounds() { soundPool = new SoundPool(4,Au@L_161_8@manager.STREAM_MUSIC,100); soundPoolMap = new HashMap<Integer,Integer>(); soundPoolMap.put(SOUND_EXPLOSION,soundPool.load(getContext(),R.raw.explosion3,1)); soundPoolMap.put(SOUND_CLEAR,R.raw.pop,1)); soundPoolMap.put(SOUND_CLICK,R.raw.click,1)); soundPoolMap.put(SOUND_MAGIC,R.raw.swoosh,1)); soundPoolMap.put(SOUND_ROCKET,R.raw.rocket,1)); soundPoolMap.put(SOUND_MELT,R.raw.melt3,1)); mgr = (Au@L_161_8@manager)getContext().getSystemservice(Context.AUdio_serviCE); }
然后通过调用以下子播放声音fx(PlaySound是由用户选项切换的全局)
public void playSound(int sound) { if (PlaySound == truE) { Log.w("playSound","Playing Sound" + sound); float streamVolumeCurrent = mgr.getStreamVolume(Au@L_161_8@manager.STREAM_MUSIC); float streamVolumeMax = mgr.getStreAMMaxVolume(Au@L_161_8@manager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; soundPool.play(soundPoolMap.get(sound),volume,1,1f); } }
你可以看到有一个日志调用,我曾经看过调用了多少次虽然这表明当发生错误时,例程只在设备听到两次声音时被调用一次.
我还有一个最后一个sub,当表面视图被破坏以便整理时调用它.
public void ReleaseSounds() { if (soundPool != null) { soundPool.release(); soundPool = null; } }
有没有其他人有这个问题,如果是这样你是如何解决它的?任何有关这方面的帮助将不胜感激,
提前谢谢了
以上是大佬教程为你收集整理的android – Soundpool和三星Galaxy S的问题全部内容,希望文章能够帮你解决android – Soundpool和三星Galaxy S的问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。