B4J Question Linux - MediaPlayer Cannot be created - Wrong URI:

hatzisn

Expert
Licensed User
Longtime User
I am getting this error when I try to play an mp3 file in MediaPlayer object in linux
MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!

The code is the following:
B4X:
    Dim savefolder As String = "delthisfolder"
    Dim sHomeFolder As String
    sHomeFolder = GetSystemProperty("user.home", "")
    If File.Exists(sHomeFolder & "/" & savefolder, "") = False Then
          File.MakeDir(sHomeFolder , savefolder)
    End If
    Dim sFolder As String = sHomeFolder & "/" & savefolder
    If File.Exists(sFolder,"PleaseWaitProcessing.mp3") = False Then
        File.Copy(File.Dirassets, "PleaseWaitProcessing.mp3", sFolder, "PleaseWaitProcessing.mp3")
    End If
    mp.Initialize("mp", File.GetUri(sFolder, "PleaseWaitProcessing.mp3"))
    mp.Play

I suspect that the problem is in the URI that creates the File.GetUri(....). The uri it creates is the following.
file:/root/delthisfolder/PleaseWaitProcessing.mp3

I tried to manually create the following but the result is the same
file:///root/delthisfolder/PleaseWaitProcessing.mp3

Any suggestions?

Tested in Ubuntu 22.04 with B4J Bridge...
 
Last edited:

hatzisn

Expert
Licensed User
Longtime User
The Java version is jdk-11.0.1 both in windows and Linux VM.

And the full log is the following:

WARNING: package com.sun.glass.ui.win not in javafx.graphics
~e:
WARNING: package com.sun.prism.d3d not in javafx.graphics
~e:
Waiting for debugger to connect...
Program started.
Error occurred on line: 187 (Main)
MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
at javafx.media/javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
at javafx.media/javafx.scene.media.MediaPlayer.init(MediaPlayer.java:518)
at javafx.media/javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:421)
at anywheresoftware.b4j.objects.MediaPlayerWrapper.Initialize(MediaPlayerWrapper.java:46)
at b4j.example.main._button1_click(main.java:147)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(S
hell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.gtk.G
tkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
at javafx.media/com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:295)
at javafx.media/com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118)
at javafx.media/javafx.scene.media.MediaPlayer.init(MediaPlayer.java:474)
... 24 more
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
With Java 14 as it is in the B4JPackager11 thread, when I try to build I get this error:

Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
I solved it (the objcopy problem) with the following installation but again the same is valid (no sound) :

sudo apt-get install binutils
 
Upvote 0
Top