You Are Here:

Community: Developer Discussion Boards

#1 Old 7650 fails with com.nokia.mid.sound - 2003-10-14, 10:05

Join Date: Oct 2003
Posts: 4
limpfish
Offline
Registered User
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.
Reply With Quote

#2 Old 2003-10-14, 10:15

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
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];
You say this causes the program to crash? Have you instantiated "sound". If not then you are getting a NullPointerException. Since getSupportedFormats() is a static function you can try:
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.

shmoove
Reply With Quote

#3 Old 2003-10-16, 11:45

Join Date: Oct 2003
Posts: 3
iori_sh
Offline
Registered User
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
Reply With Quote

#4 Old 2003-10-16, 12:17

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Try adding a call to Sound.init() before you play it.
Reply With Quote

#5 Old 2003-10-16, 15:45

Join Date: Oct 2003
Posts: 3
iori_sh
Offline
Registered User
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
Reply With Quote

#6 Old 2003-10-21, 19:23

Join Date: Oct 2003
Posts: 4
limpfish
Offline
Registered User
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia