| Reply | « Previous Thread | Next Thread » |
|
I'm having trouble using sound with a 7650. A simple midlet with no sound will work ok, but as soon as I make any reference to sound the app will fail. It will work ok with the emulator but the actual phone won't run it - the screen goes white then the app closes.
It's the same with all the example code I've tried. Nokia's MediaPlayer example won't run, but I thought maybe that was because the 7650 didn't support it. But all the example code using the 'com.nokia.mid.sound.Sound' class fails in the same way. I thought maybe it wasn't finding the com.nokia.mid.sound. class, so I tried this. try { Class.forName("com.nokia.mid.sound.Sound"); // if there is no exception then Nokia's Sound class is available // so here we can create a class that uses sound msg = "Yes!"; } catch (Exception e) { msg = "No!"; } g.drawString(msg, 10, 10, g.TOP | g.LEFT); This produced a "Yes!". The sound class is available. I commented out every reference to sound in my midlet and the app runs on the phone. Then I added this, to determine what sound is supported by the phone : int[] format = sound.getSupportedFormats(); for (int i = 0; i < format.length; i++) x += " format : " + format[i]; But even that causes the midlet to fail. Any reference to sound causes the app to crash. Whats going on? is my 7650 at fault? Am I compiling my midlet badly (all other non sound midlets work ok remember) Any help appreciated, It's driving me nuts. |
|
Nokia's MediaPlayer won't run because it uses MMAPI which is not supported on the 7650.
Now about your code: Code:
int[] format = sound.getSupportedFormats(); for (int i = 0; i < format.length; i++) x += " format : " + format[i]; Code:
int[] format = Sound.getSupportedFormats(); // notice it's "Sound" and not "sound" for (int i = 0; i < format.length; i++) x += " format : " + format[i]; shmoove |
|
I've encoutered the similar problem when I use series 60 MIDP 1.0 SDK 1.2.1. I have the code as follows
... private byte[] flySound = { (byte)0x02, (byte)0x4a, (byte)0x3a, (byte)0x80, (byte)0x40, (byte)0x01, (byte)0x12, (byte)0x04, (byte)0x58, (byte)0x4D, (byte)0x85, (byte)0x58, (byte)0x59, (byte)0x86, (byte)0x18, (byte)0x69, (byte)0x87, (byte)0x18, (byte)0x00, }; Sound sound = new Sound(flySound,Sound.FORMAT_TONE); sound.play(0); ... it always throws IllegalArgumentException though in Nokia UI API doc it says "java.lang.IllegalArgumentException - if the loop value is negative, or if sound values/data is illegal or corrupt", then the midlet exits. But it works well on 7210 emulator. Any nokia expert could help? thanx |
|
Try adding a call to Sound.init() before you play it.
|
|
yeh, I have tried to call init () before play(), , but it seems not working...
Another problem about S60 emulator is that I can't use Sound.getSupportedFormats() which is a static method. I have to create a Sound object first. Thanks |
|
me again...
>code:--------------------------------------------------------------------------->----- >int[] format = Sound.getSupportedFormats(); // notice >it's "Sound" and not "sound" > >for (int i = 0; i < format.length; i++) >x += " format : " + format[i]; >-------------------------------------------------------------------------------- > >If this doesn't crash your app, then I would guess your >problems are just a matter of bad code. Try putting all the >sound parts in try...catch blocks and see if any exceptions are >thrown during those crashes, and I'm sure you'll find the root of >your problem. It does crash my app. On both n-gage and 7650. What am I doing wrong? Can someone give me a simple example of code they know works. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|