Added shutdown hook to ensure closure of global keyboard hook.
This commit is contained in:
parent
fab04af5a6
commit
fb3c830b79
@ -70,6 +70,8 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
try {
|
try {
|
||||||
GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook();
|
GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook();
|
||||||
keyboardHook.addKeyListener(new GlobalKeyboardShortcuts());
|
keyboardHook.addKeyListener(new GlobalKeyboardShortcuts());
|
||||||
|
Thread hookShutdown = new Thread(keyboardHook::shutdownHook);
|
||||||
|
Runtime.getRuntime().addShutdownHook(hookShutdown);
|
||||||
} catch(RuntimeException | UnsatisfiedLinkError ex){
|
} catch(RuntimeException | UnsatisfiedLinkError ex){
|
||||||
System.out.println("Keyboard hook failed, global shortcuts will not work this session.");
|
System.out.println("Keyboard hook failed, global shortcuts will not work this session.");
|
||||||
System.out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user