File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Canot play an mp3 file using Java Media  Framework (JMF) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Canot play an mp3 file using Java Media  Framework (JMF)" Watch "Canot play an mp3 file using Java Media  Framework (JMF)" New topic
Author

Canot play an mp3 file using Java Media Framework (JMF)

Krishna Komarpant
Greenhorn

Joined: Aug 07, 2009
Posts: 15
Hi,
I have a VOIP program wherein when an incoming call is detected my java program picks the call and makes the caller listen to an audio. The audio message file format currently supported is .wav but i need to enable .mp3 support and not .wav (However additional support for .wav wuold be a plus point though. but .mp3 is a must.)

When i give the path of the .mp3 file in the code of my java program, the call gets picked but nothing is played. The following is the output in the jmf.log with some errors. and below that is the output with .wav audio file.




**************
jmf.log output when i give the path of the .wav audio file

Can anyone help me out with this?
Thanks in advance.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Are you using the MP3 plugin ?


[My Blog]
All roads lead to JavaRanch
Krishna Komarpant
Greenhorn

Joined: Aug 07, 2009
Posts: 15
Christophe Verré wrote:Are you using the MP3 plugin ?


Oh.. is that also required? Ok, i wil try this and check.
Krishna Komarpant
Greenhorn

Joined: Aug 07, 2009
Posts: 15
Hi again,
No, this did not work.
I added the jar in the jre home and verified that it is included in the classpath. Still it did not work. also i tried adding the jar externally and then giving the import statement

It gives the same errors.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42945
    
  68
Did you check that the MP3 plugin is correctly installed by running the JavaDecoder executable, like the web page explains?
Krishna Komarpant
Greenhorn

Joined: Aug 07, 2009
Posts: 15
Yes,
I copied the jar in the /lib/ext/ directory of the installed jre's on my system.
Closed my Java project and reopend it. I verified that the mp3 plugin was taken into the class path.

when installing the plugin, i did the following as mentioned in the website:
For the plugin to work within a JMF application, you need to :
- ensure that jmf.jar is also in the /lib/ext directory
- run the following command:
java com.sun.media.codec.audio.mp3.JavaDecoder

You should see a message that it was successfully registered, without any error message.

****And I got th success message.

Yet it did not work...
Krishna Komarpant
Greenhorn

Joined: Aug 07, 2009
Posts: 15
Following is the code related to playing the audio file:



where:
1st param: the callHandle
2nd param: MediaSourceType.MEDIA_SOURCE_FILE is a constant
3rd param: absolute filename.
4th param: loop
5th param: Initial volume
6th param: Initial Gain

I hope this will help you to get an idea about the problem.
Krishna Komarpant
Greenhorn

Joined: Aug 07, 2009
Posts: 15
Can anyone help me out with this? would be of great help to me.
Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42945
    
  68
Try this code, which seems to do things a bit differently: http://www.java2s.com/Code/Java/2D-Graphics-GUI/Mediaplayer.htm
Sweta Mulgavker
Greenhorn

Joined: Jan 05, 2009
Posts: 3
Hello ,

Try this code, which seems to do things a bit differently:
http://www.java2s.com/Code/Java/2D-Graphics-GUI/Mediaplayer.htm



This is paying a .mp3 file using a Player object. Is it a right thing to say that...

JMF needs a Player object to play the .mp3 file... but does not need it for .wav files???

Is that so?


Thanks in advance
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

JFM always needs a Player to play. However, for WAVE files you can also use the javax.sound packages and even java.applet.AudioClip.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
With Plugins from Tritonous, (mp3, ogg,..) you can only use java sound api, playing, recording mp3 or other formats without the need of jmf.

http://www.tritonus.org/
Krishna Komarpant
Greenhorn

Joined: Aug 07, 2009
Posts: 15
Tritonous is good. :-) But if i have to implement in my code then it will make me recode everything, as the current was coded with the aim to play only wav file. Now mp3 feature is required.
At one place an output format is specified: ULAW/rtp, 8000.0 Hz, 8-bit, Mono, FrameSize=8 bits


this statement forms the format string. when i provide the wav file as an input. it works, plays and gives the following output n the jmf log:


=============================
the following is the output in the jmf.log when i give the mp3 file as the input to my application:



==================
Can anyone get a hint on this problem?



Sweta Mulgavker
Greenhorn

Joined: Jan 05, 2009
Posts: 3
Hello all,

I was facing similar problems.. I made following changes


Instead of -->


I have included the following piece of code .....




These are the contents of my jmf.log




Now i am getting an error for ContentDescriptor as follows ..... (see above jmf.log file)




You can also try these changes and post if you get something....

Any help on this error will be greatly appreciated ..

Thanks and Regards...

Sweta

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Canot play an mp3 file using Java Media Framework (JMF)