Skip to content

Commit 49efb4d

Browse files
committed
solve issue #1963 (TestMusicPlayer fails to load AL library on lwjgl2) (#1964)
* TestMusicPlayer: fix UnsatisfiedLinkError when using lwjgl2. Solves issue #1963 * Add missing load function for "openal" natives. * Removed the unnecessary check for lwjgl 2 in classpath. * Fix comment
1 parent ce59ce7 commit 49efb4d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

jme3-examples/src/main/java/jme3test/audio/TestMusicPlayer.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2023 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,8 @@
4040
import com.jme3.audio.plugins.WAVLoader;
4141
import com.jme3.system.AppSettings;
4242
import com.jme3.system.JmeSystem;
43+
import com.jme3.system.NativeLibraryLoader;
44+
4345
import java.io.*;
4446
import javax.swing.JFileChooser;
4547

@@ -52,6 +54,17 @@ public class TestMusicPlayer extends javax.swing.JFrame {
5254
private float curTime = 0;
5355
final private Listener listener = new Listener();
5456

57+
static {
58+
// Load lwjgl and openal natives if lwjgl version 2 is in classpath.
59+
//
60+
// In case of lwjgl 2, natives are loaded when LwjglContext is
61+
// started, but in this test we do not create a LwjglContext,
62+
// so we should handle loading natives ourselves if running
63+
// with lwjgl 2.
64+
NativeLibraryLoader.loadNativeLibrary("lwjgl", false);
65+
NativeLibraryLoader.loadNativeLibrary("openal", false);
66+
}
67+
5568
public TestMusicPlayer() {
5669
initComponents();
5770
setLocationRelativeTo(null);

0 commit comments

Comments
 (0)