Sound problem. Restarts playing after 1 seconds or so

All your problems with Audio, Video and Images.

Sound problem. Restarts playing after 1 seconds or so

Postby ikerib » Fri Feb 25, 2011 2:29 pm

hi! I have this code:

Code: Select all
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();
    }

}

and everithing works fine except the sound. When I paint the screen

mostrarDiapositiva(diapo); we have an associated sound for every slide so if it has sound (if (diapo.tieneSonido())) it´s plays it.

the problem is that the very first time the audio starts after one or two syllable it starts again.

it´s seems like the audio starts when the slide is being painted and when it is painted it starts again. There any doevents or somethink like that?

thanks
ikerib
Freshman
Freshman
 
Posts: 2
Joined: Fri Feb 25, 2011 2:22 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 19 guests