3
它適用於幾個按鈕,但是當我點擊6左右時,只有其中一些按鈕工作。那些不起作用的錯誤(1,-19)。我做媒體播放器狀態包裝器設置,所以如果我需要使用它來獲得我的「mp」的狀態,讓我知道。當聽到播放聲音的多個按鈕時,我得到錯誤(1,19)
public class SoundFile {
public SoundFile(final Activity activity, final String soundfile, int imgButtonId, ArrayList<MediaPlayerStateWrapper> mps) {
this.mp = new MediaPlayerStateWrapper();
try {
this.afd = activity.getAssets().openFd(soundfile + ".mp3");
} catch (IOException e) {
e.printStackTrace();
}
this.allMps = mps;
mps.add(this.mp);
this.position = (ImageButton) activity.findViewById(imgButtonId);
this.position.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
mp.reset();
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
mp.prepareAsync();
mp.start();
}catch (Exception ex){
ex.printStackTrace();
}
....
這很好用 –
它最適合音板! –
這就是我用它和我的音頻錯誤停止 –