• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

MP3 on J2ME??

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys, I must programm some applications based on listenig to mp3 songs but I just can't get it. I become a "MediaException" and cannot create a player. Why is that? I have the last version of J2ME but no further specific issues on mp3. Thanks a lot
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Diana, welcome to JavaRanch!
This is the servlet forum, so you'd be lucky if someone answers your doubt. You can also try using Javaranch J2ME forum, you might get more responses there
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not a Servlet question, I'll move it to the J2ME forum for you.
Dave
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Diana,
It would help if you'd share some more information regarding the API you're using, the exception stack trace, and perhaps even some code snippets if necessary.
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello! It's Diana again (although my name is not the same). Thanks Lasse Koskela for your help.
I'm using the latest version of J2ME, which I downloaded from the sun homepage: http://java.sun.com. That is the wireless toolkit 2.0.
I have found an example for playing mp3 on J2ME here: http://www.jcp.org/en/jsr/tech?listBy=1&listByType=platform
My code is just the same, but I become this "MediaException: cannot create player" and don't know what to do. I don't know if I my device's capabilities include playing MP3-encoded streams or where to get (and put) them! I tried downloading a library, but it didn't help (or I couldn't use it correctly!!!).
Can you help me now? Thanks a lot
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure about this but I think that the WTK 2.0 doesn't support MP3 media (JSR-135 doesn't require support for any particular file formats). Test your code against a WAV file and see if it works or not (at least WAV is supported by WTK 2.0).
 
Diana Parafita
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had already done that and it works, as well as midis, but no mp3 is possible. Have you heard of any library or something?? Thanks again
 
Diana Parafita
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used a method called "getSupportedContentTypes", which returns the content types supported (obviously) and has only replied: wav, midi, and video/mpeg. So the toolkit cannot play mp3. What can I do?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Diana Parafita:
I have used a method called "getSupportedContentTypes", which returns the content types supported (obviously) and has only replied: wav, midi, and video/mpeg. So the toolkit cannot play mp3. What can I do?


Ask Google. That's all I can say, but maybe the hardcore J2ME'ers here know of an MP3 decoding/player library you could use?
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Implementing MP3 support in a Java library is very costly. If a JVM supports MP3, it almost for sure just wraps an underlying native player in the MIDP/MM API. So, if the device has a native MP3 player, there is some chance that the Java runtime might support it.
 
Diana Garc�a
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so what should I do? I have heard that maybe a mp3 player such as mpg321 may work, but I can only find Linux versions and I must work in Windows xp. Do you recommend anything? Should I use another simulator? How can I solve my problem? Please answer!
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The appropriate solution depends on what you're trying to achieve. If this is a college assignment, then it should be enough to explain to the teacher that MP3 is not supported by the available MMAPI implementations, and to make your implementation using e.g. WAV or SP-MIDI instead.
If this is a commercial product, then you need to find out if a sufficiently large target market of devices support MP3 from MMAPI. If not, maybe the market isn't ready for your product yet.
While it might be possible to write a MIDP software MP3 decoder that converts to e.g. WAV for playing, I'd guess that this is pushing the limits of the capabilities of a MIDP phone (it might not be fast enough to process a stream real-time, and might not have enough heap memory to hold the whole tune in a memory buffer).
 
Diana Garc�a
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried using JavaLayerME, which theoretically should work, but I can't compile and get:
Error preverifying class javazoom.jlme.decoder.Decoder
ERROR: floating-point constants should not appear
Build failed
Why is that? This JavaLayerME is supposed to be built to run under J2ME and J2SE, why doesn't it work properly? I tried modifying the class Decoder.java (taking the floating point constants off) but it didn't work either. Can you help?
 
Diana Garc�a
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David Price. This is a project for the university, I'm supposed to make it in order to get my ingenieur degree. I have already talked to the teachers but they say I should try and investigate. So, I have no chance and have to do it.
Diana
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Diana Garc�a:
Why is that? This JavaLayerME is supposed to be built to run under J2ME and J2SE, why doesn't it work properly? I tried modifying the class Decoder.java (taking the floating point constants off) but it didn't work either. Can you help?


You need to define what you meant by "J2ME" then. Normally, when people speak about J2ME, they refer to the MIDP -- the runtime on phones; J2ME has another popular runtime "the Personal Profile", which is a lot like J2SE and primarily runs on PDA devices. In fact, Savaje even has a version of J2SE v1.4 that runs on phones.
The JavaLayerME specifically stated that it is designed for CDC/Personal Profile devices (PDAs). So, it will not compile or run wiith any MIDP tool. But if you have a PocketPC phone, it might work. Also, if you can get a prototype phone from Savaje, you can use the standard J2SE library to play MP3.
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic