Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

trouble with sound in J2ME

Thread view: 
Jeff - 01 Apr 2006 10:18 GMT
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
Darryl L. Pierce - 10 Apr 2006 17:33 GMT
> 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?

Signature

Darryl L. Pierce <mcpierce@gmail.com>
Homepage: http://mcpierce.multiply.com/
"McVeigh's lawyer got him the death penalty, which, quite frankly,
I could have done." - Jon Stewart



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.