Fixed play button sticking for certain songs on start due to waiting for duration availability.

This commit is contained in:
neviyn 2016-03-07 15:53:03 +00:00
parent 8b3bc16f52
commit ea23faa16c
3 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,7 @@ final class LibraryUtils {
}); });
if(callbacksEnabled) if(callbacksEnabled)
callbackInterface.libraryUpdated(true); callbackInterface.libraryUpdated(true);
}); }, "libraryUpdater");
updaterThread.start(); updaterThread.start();
} }

View File

@ -68,12 +68,12 @@ class Player {
} }
playBin.setURI(songFile.toURI()); playBin.setURI(songFile.toURI());
internalThread = new InternalThread(); internalThread = new InternalThread();
thread = new Thread(internalThread); thread = new Thread(internalThread, "GSTThread");
setVolume(currentVolume); setVolume(currentVolume);
playBin.play(); playBin.play();
thread.start(); thread.start();
while (true) { 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 } // Wait for song to actually be playing otherwise queryDuration is always zero
callbackInterface.setSeekBarDuration((int) playBin.queryDuration().toSeconds()); callbackInterface.setSeekBarDuration((int) playBin.queryDuration().toSeconds());
} }

View File

@ -51,7 +51,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
running = false; running = false;
} }
} }
}); }, "seekbar");
seekBarUpdater.start(); seekBarUpdater.start();
refreshLibrary(); refreshLibrary();
} }
@ -202,7 +202,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
addNodeToTreeModel(failedModel, failedParentNode, failedNode); addNodeToTreeModel(failedModel, failedParentNode, failedNode);
libraryView.setModel(failedModel); libraryView.setModel(failedModel);
} }
}); }, "libraryRefresh");
populateThread.start(); populateThread.start();
} }