Results 1 to 3 of 3
  1. #1
    granadajose is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Playing mp3 files in Ubuntu

    Could anyone please help play an mp3 in Java on Ubuntu using the javax.media.Manager object?

    I'm building a fitness application for Ubuntu, and the mp3 sound capabilities would be a really interesting addition.

    I have used the JMF and the code described in:

    How to Play a MP3 File in Java – Simple and Beautiful

    but it simply does not work in my version of Ubuntu.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default Re: Playing mp3 files in Ubuntu

    does not work
    Are there error messages?

  3. #3
    granadajose is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Re: Playing mp3 files in Ubuntu

    Yes, I get following error message:

    ********************************
    Unable to handle format: mpeglayer3, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
    Failed to realize: com.sun.media.PlaybackEngine@14b84c7
    Error: Unable to realize com.sun.media.PlaybackEngine@14b84c7
    javax.media.CannotRealizeException
    at javax.media.Manager.blockingCall(Manager.java:2005 )
    at javax.media.Manager.createRealizedPlayer(Manager.j ava:554)
    at openfit.sonido.reproducir(sonido.java:40)
    at openfit.sonido.continuar(sonido.java:84)
    at openfit.OpenfitView$12.evaluarMusica(OpenfitView.j ava:943)
    at openfit.OpenfitView$12.buclePrincipal(OpenfitView. java:927)
    at openfit.OpenfitView$12.actionPerformed(OpenfitView .java:900)
    at javax.swing.Timer.fireActionPerformed(Timer.java:2 91)
    at javax.swing.Timer$DoPostEvent.run(Timer.java:221)
    at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:209)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:641)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:602)
    at java.awt.EventQueue$1.run(EventQueue.java:600)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 611)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
    ********************************

    I use the following code for registering the plugin:

    ********************************
    Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
    Format input2 = new AudioFormat(AudioFormat.MPEG);
    Format output = new AudioFormat(AudioFormat.LINEAR);
    PlugInManager.addPlugIn("com.sun.media.codec.audio .mp3.JavaDecoder",new Format[]{input1, input2},new Format[]{output},PlugInManager.CODEC);
    ********************************

    And the following code to (try to) play the song:

    ********************************
    player=Manager.createRealizedPlayer(new MediaLocator(new File(cancion).toURI().toURL()));
    player.start();
    ********************************

    What could be wrong?

Similar Threads

  1. Replies: 4
    Last Post: 02-26-2010, 03:18 AM
  2. JDK @ ubuntu
    By M77 in forum New To Java
    Replies: 2
    Last Post: 09-16-2009, 08:43 AM
  3. Eclipse in Ubuntu
    By DavidG24 in forum Eclipse
    Replies: 2
    Last Post: 04-18-2009, 03:10 PM
  4. SWT is not working on ubuntu
    By shreedharghare in forum SWT / JFace
    Replies: 0
    Last Post: 12-17-2008, 05:21 PM
  5. Log rotation in ubuntu
    By sarah11 in forum New To Java
    Replies: 0
    Last Post: 11-04-2008, 07:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •