×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    12

    Playing WAV files on 7650

    Hi,

    I need to play small WAV files on Nokia 7650.
    On the emulator I successfully used the Mobile Media APIs(javax.microedition.media) with the Player interface and everything was OK.

    On the real 7650 it seems that this library is not (yet?) supported and the application crashes.

    So I used the com.nokia.mid.sound library (Sound / SoundListener), that works also in the real 7650, but I found many bugs; the most important is that it seems that SoundListener Interface is not (yet?) supported neither on emulator nor in 7650.
    If so, how can I get the SOUND_STOPPED event or similar?

    Is there also a workaround for the SetGain() bug?

    Thanks!

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Tampere / Finland
    Posts
    201

    RE: Playing WAV files on 7650

    Hello,

    Only Nokia 3650 supports the Mobile Media API, 7650 doesn't support it.

    SetGain() in com.mid.sound doesn't work properly, Could you post the fraction of code using the SoundListener and Sound event, then I can take a look and investigate it. It might be a bug.

    Regards,
    Kui

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Tampere / Finland
    Posts
    201

    RE: Playing WAV files on 7650

    Hello,

    The SoundListener and SoundEvent work in both emulator and real 7650. The sound shound be registered a listener for playback state notification by using setSoundListener(SoundListener listener). But in my test, no matter the state changes or not, the soundStateChanged(Sound sound, int event) was called after every steps during the process(ex. the sound be constracted, be initiated and be played).

    Here is the test code, hope it helps you.

    ----------------------------------------------------------------------
    package ring;

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import com.nokia.mid.sound.*;
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;

    public class Ring extends MIDlet implements CommandListener, SoundListener
    {
    private Display display = null;
    private List list = null;

    private Sound soundOtt = null;
    private Sound soundBinaryArray = null;
    private Sound soundWav = null;
    private Sound soundNote = null;


    private final static byte[] BYTES =
    {
    (byte)0x02, (byte)0x4a, (byte)0x3a, (byte)0x69,
    (byte)0x8c, (byte)0xe9, (byte)0x71, (byte)0x99,
    (byte)0xbd, (byte)0xc9, (byte)0xd5, (byte)0xb5,
    (byte)0xb9, (byte)0xbc, (byte)0x04, (byte)0x00,
    (byte)0x10, (byte)0xd9, (byte)0x65, (byte)0x13,
    (byte)0x82, (byte)0x4c, (byte)0x40, (byte)0x8c,
    (byte)0x09, (byte)0xc4, (byte)0x00
    };

    private final static String PATH = "/brianboru.ott";

    public Ring()
    {
    list = new List("Sound in MIDP", List.IMPLICIT);
    list.append("Play Ott File", null);
    list.append("Play Binary Array", null);
    list.append("Play Wav File", null);
    list.append("Play Note", null);
    list.setCommandListener(this);

    /*int[] format = sound.getSupportedFormats();
    for (int i = 0; i < format.length; i++)
    System.out.println("The supported formats include1 - FORMAT_TONE, 5 - FORMAT_WAV) " + format[i]);*/

    System.out.println(System.getProperty("microedition.locale&quot); // return the language code and the country code
    System.out.println(System.getProperty("microedition.profiles&quot); // return the Profiles
    System.out.println(System.getProperty("microedition.platform&quot); // return the model and software version of the phone*/

    }

    protected void destroyApp(boolean p0) throws MIDletStateChangeException {}

    protected void startApp() throws MIDletStateChangeException
    {
    Display.getDisplay(this).setCurrent(list);
    }

    protected void pauseApp() {}

    public void commandAction (Command c, Displayable d)
    {
    if (c == List.SELECT_COMMAND)
    {
    if(list.getSelectedIndex() == 0)
    {
    System.out.print("Playing Ott File"
    try
    {
    InputStream tune = this.getClass().getResourceAsStream("/brianboru.ott"
    byte[] buffer = new byte[500];
    tune.read(buffer, 0, buffer.length);
    soundOtt = new Sound(buffer, Sound.FORMAT_TONE);
    soundOtt.init(buffer, Sound.FORMAT_TONE);
    soundOtt.setSoundListener(this);
    soundOtt.play(1);
    buffer = null;
    } catch (Exception e) {}
    soundOtt.play(1);
    }

    if(list.getSelectedIndex() == 1)
    {
    System.out.print("Playing Binary Array"
    soundBinaryArray = new Sound(BYTES, Sound.FORMAT_TONE);
    soundBinaryArray.init(BYTES, Sound.FORMAT_TONE);
    soundBinaryArray.setSoundListener(this);
    soundBinaryArray.play(1);
    }

    if(list.getSelectedIndex() == 2)
    {
    System.out.print("Playing talkforever16 WAV file"
    try
    {
    InputStream tune = this.getClass().getResourceAsStream("/talkforever16.wav"
    byte[] buffer = new byte[100000];
    tune.read(buffer, 0, buffer.length);
    soundWav = new Sound(buffer, Sound.FORMAT_WAV);
    soundWav.init(buffer, Sound.FORMAT_WAV);
    soundWav.setSoundListener(this);
    soundWav.play(1);
    buffer = null;
    } catch (Exception e) {}
    //sound1.play(1);
    }

    if(list.getSelectedIndex() == 3)
    {
    System.out.print("Playing Note"
    soundNote = new Sound(1000, 1000);
    soundNote.init(1000, 1000);
    soundNote.setSoundListener(this);
    soundNote.play(1);
    }
    }
    }

    public void soundStateChanged(Sound sound, int event)
    {
    if (sound == soundOtt)
    {
    if (event == Sound.SOUND_PLAYING) System.out.println("SoundOtt begin playing"
    if (event == Sound.SOUND_STOPPED) System.out.println("SoundOtt end playing"
    }

    if (sound == soundBinaryArray)
    {
    if (event == Sound.SOUND_PLAYING) System.out.println("SoundBinaryArray begin playing"
    if (event == Sound.SOUND_STOPPED) System.out.println("SoundBinaryArray end playing"
    }

    if (sound == soundWav)
    {
    if (event == Sound.SOUND_PLAYING)
    {
    System.out.println("SoundWav begin playing"
    TextBox textBox = new TextBox ("Wav file", "Now it's playing Wav file", 100, 1);
    display.getDisplay(this).setCurrent(textBox);
    }
    if (event == Sound.SOUND_STOPPED)
    {
    System.out.println("SoundWav end playing"
    display.getDisplay(this).setCurrent(list);
    }
    }

    if (sound == soundNote)
    {
    if (event == Sound.SOUND_PLAYING) System.out.println("SoundNote begin playing"
    if (event == Sound.SOUND_STOPPED) System.out.println("SoundNote end playing"
    }

    }

    }
    ----------------------------------------------------------------------

    Regards,
    Kui

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×