Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java Micro Edition
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java Micro Edition
mmapi problem
pingkan paula
Ranch Hand
Posts: 117
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm developing a simple mp3 player, but when i run it didn't perform anything
Here is the code, any feedbacks for my mistake will be fully appreciated
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.media.*; import java.io.*; public class animasiMidlet extends MIDlet implements CommandListener{ private animasiPlay play; private Display d; private InputStream in; private Player p; public animasiMidlet(){ d=Display.getDisplay(this); play=new animasiPlay(this); d.setCurrent(new MenuScreen(this)); } public void startApp(){ } public void displayMain(){ try{ d.setCurrent(new MenuScreen(this)); }catch(Exception e){ System.out.println("display main exception:"+e.toString()); } } public void pauseApp(){} public void destroyApp(boolean unconditional){ notifyDestroyed(); } public void commandAction(Command c,Displayable d){ if(c.getLabel().equals("Play")){ playSong(); } else if(c.getLabel().equals("Exit")){ this.destroyApp(false); } } public void playSong(){ try{ in=getClass().getResourceAsStream("/musik/ifOnly.mp3"); p=Manager.createPlayer(in ,"audio/mpeg"); //my debug 1System.out.println("1"); p.realize(); //my debug 2 which didnt appear System.out.println("2"); p.prefetch(); p.start(); boolean flag = false; do { if(flag) break; if(p.getMediaTime() > p.getDuration() || p.getMediaTime() > 0x989680L) { stopSong(); flag = true; } } while(true); } catch(IOException ie){ System.out.println(""); } catch(MediaException me){ } } public void stopSong() { try { p.stop(); in.close(); p = null; in = null; System.gc(); } catch(MediaException mediaexception) { mediaexception.printStackTrace(); } catch(IOException ioexception) { ioexception.printStackTrace(); } } }
payal agrawal
Ranch Hand
Posts: 44
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Have a Look at these URLS.
Playing MP3 from your local file on J2ME devices
http://www.java-tips.org/content/view/154/39/
Playing MP3 files from your server on J2ME devices
http://www.java-tips.org/content/view/153/39/
Finding multimedia content-type support of a mobile device
http://www.java-tips.org/content/view/155/39/
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Stream MP3 To Mobile
can't play video from URL
problem playing video and audio
MediaException: premature end of stream
problem with mmapi...urgent
More...