Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > trouble with sound in J2ME

Reply
Thread Tools

trouble with sound in J2ME

 
 
Jeff
Guest
Posts: n/a
 
      04-01-2006
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


 
Reply With Quote
 
 
 
 
Darryl L. Pierce
Guest
Posts: n/a
 
      04-10-2006
Jeff wrote:

> 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 <(E-Mail Removed)>
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 ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble getting new sound card to work - had onboard sound Dora Smith Computer Information 1 11-23-2006 04:31 PM
Will application J2ME MIDP 2.0 based of one device run another J2ME MIDP 2.0 device? nishadixit Java 5 06-01-2005 05:40 AM
J2ME/ktoolbar: Send an sms to an emulated J2ME-App Markus Java 4 02-12-2005 01:20 PM
J2ME Lime error 10061 (Re: Help with J2ME Wireless Toolkit) Boldra Java 0 12-03-2003 11:30 AM
Can i using j2me program to download and run other j2me programs in emulator? robin Java 0 07-20-2003 12:59 AM



Advertisments