From fa31999dafb1adc4afd0c8ee20b80b44ad3cdb08 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Tue, 8 May 2018 01:43:01 +0300 Subject: [PATCH] v0.9 Fixed bug when embedded subtitles doesn't superseded by stand-alone subtitles. Added button for disable subtitles (all kind). Status of this button saved and restored on application startup. --- AppPreferences.java | 6 +++++ Controller.java | 39 +++++++++++++++++++++++++++++++ Main.java | 2 +- landingPage.fxml | 8 +++++++ localization/locale_en.properties | 3 ++- localization/locale_ru.properties | 3 ++- 6 files changed, 58 insertions(+), 3 deletions(-) diff --git a/AppPreferences.java b/AppPreferences.java index 52c1303..1e321f0 100644 --- a/AppPreferences.java +++ b/AppPreferences.java @@ -76,6 +76,12 @@ public class AppPreferences { } public void setFullScreenSelected(boolean set){ preferences.putBoolean("FULL_SCREEN_SELECTED", set); } + // Save & recover Subtitles checkbox, if selected + public boolean getSubtitlesHideSelected(){ + return preferences.getBoolean("FULL_SUBTITLES_HIDE_SELECTED", false); + } + public void setSubtitlesHideSelected(boolean set){ preferences.putBoolean("FULL_SUBTITLES_HIDE_SELECTED", set); } + /** Lists managment */ // Return lists itself of the latest opened folders (used only in Controller.class) private String getList(String whichList){ diff --git a/Controller.java b/Controller.java index e46374f..482b2de 100644 --- a/Controller.java +++ b/Controller.java @@ -38,6 +38,9 @@ public class Controller implements Initializable { @FXML private TabPane tabPane; + @FXML + private CheckMenuItem subsHide; + @Override public void initialize(URL url, ResourceBundle rb) { // Register this controller in mediator @@ -80,6 +83,7 @@ public class Controller implements Initializable { } } fullScreen.setSelected(appPreferences.getFullScreenSelected()); + subsHide.setSelected(appPreferences.getSubtitlesHideSelected()); } public void setHostServices(HostServices hostServices) { @@ -96,6 +100,31 @@ public class Controller implements Initializable { return true; } else { return false; } } + + @FXML + private void subsTriggerBtn(){ + playerSingleCommand("get_sub_visibility"); + String returnedStr; + int returnedInt = 1; + try { + while ((returnedStr = playerOutErr.readLine()) != null) { + //System.out.println(returnedStr); + if (returnedStr.startsWith("ANS_SUB_VISIBILITY=")) { + returnedInt = Integer.parseInt(returnedStr.substring("ANS_SUB_VISIBILITY=".length())); + break; + } + } + } + catch (IOException e) { + System.out.println("Can't determine if subtitles enabled/disabled"); + } + + if (returnedInt == 1) + playerSingleCommand("sub_visibility 0"); + else + playerSingleCommand("sub_visibility 1"); + + } @FXML private void fullscreenBtn(){ playerSingleCommand("vo_fullscreen"); } @FXML @@ -148,6 +177,7 @@ public class Controller implements Initializable { "-quiet", fullScreen.isSelected() ? "-fs" : "", mkvPaneController.paneFileList.get(mkvPaneController.paneListView.getSelectionModel().getSelectedIndex()).toPath().toString(), + subsHide.isSelected()||Subtitles?"-nosub":"", // Turn off subtitles embedded into MKV file (and replace by localy-stored subs file if needed) Subtitles?"-sub":"", Subtitles? subPaneController.paneFileList.get(mkvPaneController.paneListView.getSelectionModel().getSelectedIndex()).toPath().toString():"", Subtitles?SubCodepageDefault?"":"-subcp":"", // Use subtitles -> YES -> Check if we need codepage @@ -163,6 +193,14 @@ public class Controller implements Initializable { new LineRedirecter(player.getErrorStream(), writeTo).start(); playerIn = new PrintStream(player.getOutputStream()); + + /* If user desired to disable subtitles but populated the list in the SUB pane, then load them and disable visibility. + * It's should be done this way because if we won't pass them to mplayer during start them user won't be able to enable them later on. + * There is another bike could be implemented such as passing input file during load but it's far more dumb idea then current implementation. + */ + if (subsHide.isSelected()) + playerSingleCommand("sub_visibility 0"); + } else { playerIn.print("pause"); playerIn.print("\n"); @@ -210,6 +248,7 @@ public class Controller implements Initializable { appPreferences.setLastTimeUsedSusExt(subPaneController.subtExt.getValue()); appPreferences.setLastTimeUsedSubsCodepage(subPaneController.subtCodepage.getValue()); appPreferences.setFullScreenSelected(fullScreen.isSelected()); + appPreferences.setSubtitlesHideSelected(subsHide.isSelected()); Platform.exit(); } diff --git a/Main.java b/Main.java index b56532c..ec97e75 100644 --- a/Main.java +++ b/Main.java @@ -3,7 +3,7 @@ package mplayer4anime; * Name: mplayer4anime * * Author: Dmitry Isaenko * * License: GNU GPL v.3 * -* Version: 0.8.4 * +* Version: 0.9 * * Site: https://developersu.blogspot.com/ * * 2018, Russia * ***********************************************/ diff --git a/landingPage.fxml b/landingPage.fxml index b4dcd4c..1329234 100644 --- a/landingPage.fxml +++ b/landingPage.fxml @@ -69,6 +69,14 @@ + + + + + + + + diff --git a/localization/locale_en.properties b/localization/locale_en.properties index 25da83d..2202bcd 100644 --- a/localization/locale_en.properties +++ b/localization/locale_en.properties @@ -1,5 +1,5 @@ about_line1=mplayer4amine distributes under GNU GPLv3 license. -about_line2=Release: v0.8.4 +about_line2=Release: v0.9 about_line3=Development & maintenance by Dmitry Isaenko. about_AboutName=About main_tab_audio=Audio @@ -24,4 +24,5 @@ settings_LoadListsOnStart=Save & restore previously opened lists after applicati settings_subsExtensionList=Avaliable subtitles extensions: settings_subsCodepageList=Avaliable codepages for subtitles: settings_fieldContainSpacesTabs=Spaces and tab symbols are not allowed. +subsShow_option=Don't show subtitles. diff --git a/localization/locale_ru.properties b/localization/locale_ru.properties index 49126d7..3c135cf 100644 --- a/localization/locale_ru.properties +++ b/localization/locale_ru.properties @@ -1,5 +1,5 @@ about_line1=mplayer4amine \u0440\u0430\u0441\u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u044F\u0435\u0442\u0441\u044F \u043F\u043E \u043B\u0438\u0446\u0435\u043D\u0437\u0438\u0438 GNU GPLv3. -about_line2=\u0420\u0435\u043B\u0438\u0437: v0.8.4 +about_line2=\u0420\u0435\u043B\u0438\u0437: v0.9 about_line3=\u0420\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u0430\u043D\u043E \u0438 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u0414\u043C\u0438\u0442\u0440\u0438\u0435\u043C \u0418\u0441\u0430\u0435\u043D\u043A\u043E. about_AboutName=\u041E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438 main_tab_audio=\u0410\u0443\u0434\u0438\u043E @@ -24,3 +24,4 @@ settings_LoadListsOnStart=\u0417\u0430\u043F\u043E\u043C\u0438\u043D\u0430\u0442 settings_subsExtensionList=\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043D\u0438\u044F \u0434\u043B\u044F \u0441\u0443\u0431\u0442\u0438\u0442\u0440\u043E\u0432: settings_subsCodepageList=\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u043A\u043E\u0434\u0438\u0440\u043E\u0432\u043A\u0438 \u0434\u043B\u044F \u0441\u0443\u0431\u0442\u0438\u0442\u0440\u043E\u0432: settings_fieldContainSpacesTabs=\u041F\u0440\u043E\u0431\u0435\u043B\u044B \u0438 \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u0442\u0430\u0431\u0443\u043B\u044F\u0446\u0438\u0438 \u043D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B. +subsShow_option=\u041D\u0435 \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0442\u044C \u0441\u0443\u0431\u0442\u0438\u0442\u0440\u044B.