trouble with sound in J2ME

J

Jeff

midp 2.0
Java SE 5.0
J2ME version 2.2

Below is a piece of code I've having problems with playing on my handset
(nokia 6630), it starts to play but the then stops... it doesn't finiesh the
song it play for ca 1 second and then stops....

This code below is my trouble code:
try {
System.out.println("Sound block starts");
InputStream is = getClass().getResourceAsStream("/test.mid");
Player player = Manager.createPlayer(is, "audio/midi");
player.start();
System.out.println("Sound block ends");
}
catch (IOException ioe) {
}
catch (MediaException me) {
}

Overview of threads in my midlet:
main thread (threadA)- this thread is listening for responses from the
handset for example....
-> a new thread (threadB) and this is the thread the program is executed
within
It's in the threadB my trouble code is within....

My midlet has 2 threads: threadA, threadB

I created a simple test midlet where my trouble code was executed on main
thread (the midlet had only one thread) and everything works fine...

But why is it playing only 1 second in my trouble code?.... what must I do
to fix this?.... I guess I maybe could have executed the music playing from
the main thread but that again will give me lots of trouble as the sound
should be syncronized with the actions in threadB

Please give me some advice....

Jeff
 
D

Darryl L. Pierce

Jeff said:
But why is it playing only 1 second in my trouble code?.... what must I do
to fix this?.... I guess I maybe could have executed the music playing
from the main thread but that again will give me lots of trouble as the
sound should be syncronized with the actions in threadB

No, you should not start play from the main thread. Are you sure the sound
file being executed is more than one second in length? Did your sample code
execute the exact same sound file?

--
Darryl L. Pierce <[email protected]>
Homepage: http://mcpierce.multiply.com/
"McVeigh's lawyer got him the death penalty, which, quite frankly,
I could have done." - Jon Stewart
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top