Android中的声音(StreamingMediaPlayer无法正常工作,无法正常工作)
问题描述:
private void mostrarDiapositiva(Vector<Diapositiva> d, int pos) {
if (pos >= d.size()) {
pos = d.size() - 1;
}
Diapositiva diapo = d.get(pos);
this.setDiapoPosActual(pos);
this.setDiapoActual(diapo);
reiniciarDiapositiva();
mostrarDiapositiva(diapo);
try {
if (diapo.tieneSonido()) {
String sndPath = ZIP_SND_PATH + diapo.getSonido().getNombre();
InputStream isSonido = this.getTutorFile().getFile(sndPath);
this.audioPlayer = new StreamingMediaPlayer(this);
this.audioPlayer.startStreaming(isSonido);
} else if (diapo.tieneVideo()) {
if (!diapo.tieneImagen()) {
String imgPath = ZIP_FONDOS_PATH + "fondo_video.png";
cargarImagen(imgPath);
}
}
} catch (Throwable ex) {
Log.e("mostrarDiapositiva", ex.getMessage());
Toast
.makeText(this, "Error: " + ex.getMessage(), Toast.LENGTH_SHORT)
.show();
}
}
private void mostrarDiapositiva(Diapositiva diapo) {
ImageButton bp = (ImageButton) findViewById(R.id.buttonprev);
bp.setImageResource(R.drawable.ic_menu_back);
ImageButton bn = (ImageButton) findViewById(R.id.buttonnext);
bn.setImageResource(R.drawable.ic_menu_forward);
try {
if (diapo.tieneImagen()) {
String imgPath = ZIP_IMG_PATH + diapo.getImagen().getNombre();
cargarImagen(imgPath);
}
this.animarFade(this.FLIPPER_DIAPOS_NUMLAYOUT);
//if (diapo.tieneSonido()) {
// String sndPath = ZIP_SND_PATH + diapo.getSonido().getNombre();
// InputStream isSonido = this.getTutorFile().getFile(sndPath);
} catch (Throwable ex) {
Log.e("mostrarDiapositiva", ex.getMessage());
Toast
.makeText(this, "Error: " + ex.getMessage(), Toast.LENGTH_SHORT)
.show();
}
}
除了声音以外,当我画屏Android中的声音(StreamingMediaPlayer无法正常工作,无法正常工作)
mostrarDiapositiva(diapo); 我们有每张幻灯片的相关声音,所以如果它有声音(如果(diapo.tieneSonido()))它播放它。
问题是,第一次音频开始后,一个或两个音节重新开始。
它看起来像音频开始时,幻灯片正在着色,当它被绘了它再次开始。有没有什么事情或类似的东西?
感谢
答
该作品在一个类似的案件:
MediaPlayer mp = new MediaPlayer();
// when you want to play the sound stored in nodeaudio:
// nodeaudio is a path like /min/sdcard/soundfile
if (nodeaudio == null || nodeaudio.trim().equals("")) {
mp.reset();
}
else {
try {
mp.reset();
mp.setDataSource(nodeaudio);
mp.prepare();
mp.start();
}
catch(Exception e) {
Log.e("Play sound ERROR", e.toString());
e.printStackTrace();
}
}
对这个问题的标题可能比“的声音在Android的”更好的为我们这些搜索。 – 2011-03-11 16:52:33