Simplified playback engine selection.

This commit is contained in:
neviyn 2016-12-05 14:51:16 +00:00
parent 1cd6bfccfc
commit a98ef2209e

View File

@ -25,20 +25,15 @@ class SwingUIModule extends AbstractModule {
bind(IPlaylist.class).to(TabbedJTablePlaylist.class).in(Singleton.class);
bind(ILibrary.class).to(JTreeLibrary.class).in(Singleton.class);
bind(PlayerCallbackInterface.class).to(PlayerGUI.class).in(Singleton.class);
String engineName = ConfigManager.getPlayerEngine();
boolean engineSet = false;
for(Engine engine : Engine.values()){
if(engineName.equals(engine.getEngineName()) && engine.isAvailable()){
bind(IPlayer.class).to(engine.getEngineImplementation()).in(Singleton.class);
ConfigManager.setPlayerEngine(engine.getEngineName());
engineSet = true;
}
}
if(!engineSet){ // If the user has set an invalid engine, try and set a usable one.
for(Engine engine : Engine.values()){
if(engine.isAvailable()){
bind(IPlayer.class).to(engine.getEngineImplementation()).in(Singleton.class);
ConfigManager.setPlayerEngine(engine.getEngineName());
Engine engine = Engine.valueOf(ConfigManager.getPlayerEngine());
if (engine.isAvailable()) {
bind(IPlayer.class).to(engine.getEngineImplementation()).in(Singleton.class);
ConfigManager.setPlayerEngine(engine.getEngineName());
} else { // If the user has set an invalid engine, try and set a usable one.
for (Engine potentialEngine : Engine.values()) {
if (potentialEngine.isAvailable()) {
bind(IPlayer.class).to(potentialEngine.getEngineImplementation()).in(Singleton.class);
ConfigManager.setPlayerEngine(potentialEngine.getEngineName());
break;
}
}