From ea23faa16c98a7d5dd754d4db46280993e6859f4 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Mon, 7 Mar 2016 15:53:03 +0000 Subject: [PATCH] Fixed play button sticking for certain songs on start due to waiting for duration availability. --- src/main/java/musicplayer/LibraryUtils.java | 2 +- src/main/java/musicplayer/Player.java | 4 ++-- src/main/java/musicplayer/PlayerGUI.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/musicplayer/LibraryUtils.java b/src/main/java/musicplayer/LibraryUtils.java index bfd6b42..41c1b28 100644 --- a/src/main/java/musicplayer/LibraryUtils.java +++ b/src/main/java/musicplayer/LibraryUtils.java @@ -45,7 +45,7 @@ final class LibraryUtils { }); if(callbacksEnabled) callbackInterface.libraryUpdated(true); - }); + }, "libraryUpdater"); updaterThread.start(); } diff --git a/src/main/java/musicplayer/Player.java b/src/main/java/musicplayer/Player.java index 256a75a..3b5ad74 100644 --- a/src/main/java/musicplayer/Player.java +++ b/src/main/java/musicplayer/Player.java @@ -68,12 +68,12 @@ class Player { } playBin.setURI(songFile.toURI()); internalThread = new InternalThread(); - thread = new Thread(internalThread); + thread = new Thread(internalThread, "GSTThread"); setVolume(currentVolume); playBin.play(); thread.start(); while (true) { - if (playBin.queryDuration().getNanoSeconds() > 0) break; + if (playBin.queryDuration().getSeconds() > 0 || playBin.queryDuration().getNanoSeconds() > 0) break; } // Wait for song to actually be playing otherwise queryDuration is always zero callbackInterface.setSeekBarDuration((int) playBin.queryDuration().toSeconds()); } diff --git a/src/main/java/musicplayer/PlayerGUI.java b/src/main/java/musicplayer/PlayerGUI.java index 415197d..65dfde4 100644 --- a/src/main/java/musicplayer/PlayerGUI.java +++ b/src/main/java/musicplayer/PlayerGUI.java @@ -51,7 +51,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf running = false; } } - }); + }, "seekbar"); seekBarUpdater.start(); refreshLibrary(); } @@ -202,7 +202,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf addNodeToTreeModel(failedModel, failedParentNode, failedNode); libraryView.setModel(failedModel); } - }); + }, "libraryRefresh"); populateThread.start(); }