Android lengthen sound clips
I have created a number of sound clips using Audacity and have them exported them as .OGG files into the soundpool. Some of the longer clips stop early though. Is there a set length for each clip in the soundpool? Is it something I can extend?
Here is my SoundManager:
package com.androidbook.ufgsoundboard;
import java.util.HashMap;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
public class SoundManager {
private SoundPool mSoundPool;
private HashMap<Integer, Integer> mSoundPoolMap;
private AudioManager mAudioManager;
private Context mContext;
public static final int maxSounds = 1;
public SoundManager()
{
}
public void initSounds(Context theContext) {
mContext = theContext;
mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
mSoundPoolMap = new HashMap<Integer, Integer>();
mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
}
public void addSound(int Index,int SoundID)
{
mSoundPoolMap.put(Index, mSoundPool.load(mContext, SoundID, 1));
}
public void playSound(int index) {
int streamVolume = mAudioManager.getStreamVolume(开发者_StackOverflow中文版AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, 1f);
}
}
I needed to save my original sound clips in Audacity as 11025 HZ 16-bit OGG files. This allows the clips to be as long as I want.
精彩评论