B4J Question [SOLVED] Playing mp3 in Ubuntu / Debian

aberezhnykh

Member
Licensed User
I have an application that works well on Windows and Mac. I'm trying to run the application on Ubuntu / Debian, but the attempt was not successful. I found that the codecs for mp3 are problematic. For example, I made a simple code that ends with an error. Is there a solution to this problem? Thank you!
B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
'    MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
    Dim mediaPlayer As MediaPlayer
    Dim url As String = "http://ol3.mp3party.net/online/3401/3401743.mp3"
    mediaPlayer.Initialize("mediaPlayer", url)
    mediaPlayer.Play
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
Result:

Waiting for debugger to connect...
Program started.
MediaException: MEDIA_UNSUPPORTED : [] ERROR_MEDIA_AUDIO_FORMAT_UNSUPPORTED: ERROR_MEDIA_AUDIO_FORMAT_UNSUPPORTED
at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2610)
at com.sun.media.jfxmediaimpl.MediaUtils.nativeError(MediaUtils.java:293)
at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia.init(GSTMedia.java:69)
at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia.<init>(GSTMedia.java:52)
at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer.<init>(GSTMediaPlayer.java:62)
at com.sun.media.jfxmediaimpl.platform.gstreamer.GSTPlatform.createMediaPlayer(GSTPlatform.java:121)
at com.sun.media.jfxmediaimpl.platform.PlatformManager.createMediaPlayer(PlatformManager.java:201)
at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:222)
at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:104)
at javafx.scene.media.MediaPlayer.init(Me
diaPlayer.java:467)
at javafx.scene.media.MediaPlayer.access$1000(MediaPlayer.java:150)
at javafx.scene.media.MediaPlayer$InitMediaPlayer.run(MediaPlayer.java:525)
at java.lang.Thread.run(Thread.java:748)
 

stevel05

Expert
Licensed User
Presumably you need to install the correct codec for Ubuntu.

Alternatively you could make sure that the mp3 is encoded in a format that the mediaplayer already has a codec for.

Did you encode the mp3? Do you know what format it is? It sounds like it is not a standard format

Have you tried any other MP3's?
 
Top