Prevents the browser from locking on shutdown if the browser ran into a startup error.

This commit is contained in:
Markil3
2021-09-15 09:35:16 -06:00
parent f7370ba08a
commit f8be50af9d
3 changed files with 20 additions and 4 deletions

View File

@@ -46,6 +46,7 @@ public class PlayerEnvironment
*/
public static void main(String[] args)
{
logger.info("MAIN FOREVER");
LinkedHashMap<String, Object> ops = new LinkedHashMap<>();
ArrayList<String> params = new ArrayList<>();
parseArgs(args, ops, params);

View File

@@ -33,6 +33,7 @@ public class BrowserPlayer implements Player<InternetSong>, UpdateListener
.getLogger(BrowserPlayer.class);
private final LinkedList<PlaybackListener> listeners = new LinkedList<>();
private boolean error = false;
private InternetSong currentSong;
@@ -40,9 +41,9 @@ public class BrowserPlayer implements Player<InternetSong>, UpdateListener
private Browser getBrowser()
{
if (browserRef == null)
if (browserRef == null && !this.error)
{
while (Browser.getInstance() == null)
if (Browser.getInstance() == null)
{
try
{
@@ -53,8 +54,11 @@ public class BrowserPlayer implements Player<InternetSong>, UpdateListener
logger.error("Interrupted while waiting for browser to initialize.", e);
}
}
Browser.getInstance().addUpdateListener(this);
browserRef = Browser.getInstance();
if (Browser.getInstance() != null)
{
Browser.getInstance().addUpdateListener(this);
browserRef = Browser.getInstance();
}
}
return browserRef;
}
@@ -70,6 +74,8 @@ public class BrowserPlayer implements Player<InternetSong>, UpdateListener
catch (IOException | InterruptedException e)
{
logger.error("Could not initialize browser", e);
this.error = true;
Browser.notifyAllInstance();
}
});
browserThread.start();