Skip to content

Commit fa31999

Browse files
committed
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.
1 parent a22827d commit fa31999

File tree

6 files changed

+58
-3
lines changed

6 files changed

+58
-3
lines changed

AppPreferences.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ public boolean getFullScreenSelected(){
7676
}
7777
public void setFullScreenSelected(boolean set){ preferences.putBoolean("FULL_SCREEN_SELECTED", set); }
7878

79+
// Save & recover Subtitles checkbox, if selected
80+
public boolean getSubtitlesHideSelected(){
81+
return preferences.getBoolean("FULL_SUBTITLES_HIDE_SELECTED", false);
82+
}
83+
public void setSubtitlesHideSelected(boolean set){ preferences.putBoolean("FULL_SUBTITLES_HIDE_SELECTED", set); }
84+
7985
/** Lists managment */
8086
// Return lists itself of the latest opened folders (used only in Controller.class)
8187
private String getList(String whichList){

Controller.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class Controller implements Initializable {
3838
@FXML
3939
private TabPane tabPane;
4040

41+
@FXML
42+
private CheckMenuItem subsHide;
43+
4144
@Override
4245
public void initialize(URL url, ResourceBundle rb) {
4346
// Register this controller in mediator
@@ -80,6 +83,7 @@ public void initialize(URL url, ResourceBundle rb) {
8083
}
8184
}
8285
fullScreen.setSelected(appPreferences.getFullScreenSelected());
86+
subsHide.setSelected(appPreferences.getSubtitlesHideSelected());
8387
}
8488

8589
public void setHostServices(HostServices hostServices) {
@@ -96,6 +100,31 @@ private boolean playerSingleCommand(String command){
96100
return true;
97101
} else { return false; }
98102
}
103+
104+
@FXML
105+
private void subsTriggerBtn(){
106+
playerSingleCommand("get_sub_visibility");
107+
String returnedStr;
108+
int returnedInt = 1;
109+
try {
110+
while ((returnedStr = playerOutErr.readLine()) != null) {
111+
//System.out.println(returnedStr);
112+
if (returnedStr.startsWith("ANS_SUB_VISIBILITY=")) {
113+
returnedInt = Integer.parseInt(returnedStr.substring("ANS_SUB_VISIBILITY=".length()));
114+
break;
115+
}
116+
}
117+
}
118+
catch (IOException e) {
119+
System.out.println("Can't determine if subtitles enabled/disabled");
120+
}
121+
122+
if (returnedInt == 1)
123+
playerSingleCommand("sub_visibility 0");
124+
else
125+
playerSingleCommand("sub_visibility 1");
126+
127+
}
99128
@FXML
100129
private void fullscreenBtn(){ playerSingleCommand("vo_fullscreen"); }
101130
@FXML
@@ -148,6 +177,7 @@ private void playBtn(){
148177
"-quiet",
149178
fullScreen.isSelected() ? "-fs" : "",
150179
mkvPaneController.paneFileList.get(mkvPaneController.paneListView.getSelectionModel().getSelectedIndex()).toPath().toString(),
180+
subsHide.isSelected()||Subtitles?"-nosub":"", // Turn off subtitles embedded into MKV file (and replace by localy-stored subs file if needed)
151181
Subtitles?"-sub":"",
152182
Subtitles? subPaneController.paneFileList.get(mkvPaneController.paneListView.getSelectionModel().getSelectedIndex()).toPath().toString():"",
153183
Subtitles?SubCodepageDefault?"":"-subcp":"", // Use subtitles -> YES -> Check if we need codepage
@@ -163,6 +193,14 @@ private void playBtn(){
163193
new LineRedirecter(player.getErrorStream(), writeTo).start();
164194

165195
playerIn = new PrintStream(player.getOutputStream());
196+
197+
/* If user desired to disable subtitles but populated the list in the SUB pane, then load them and disable visibility.
198+
* 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.
199+
* There is another bike could be implemented such as passing input file during load but it's far more dumb idea then current implementation.
200+
*/
201+
if (subsHide.isSelected())
202+
playerSingleCommand("sub_visibility 0");
203+
166204
} else {
167205
playerIn.print("pause");
168206
playerIn.print("\n");
@@ -210,6 +248,7 @@ public void shutdown(){
210248
appPreferences.setLastTimeUsedSusExt(subPaneController.subtExt.getValue());
211249
appPreferences.setLastTimeUsedSubsCodepage(subPaneController.subtCodepage.getValue());
212250
appPreferences.setFullScreenSelected(fullScreen.isSelected());
251+
appPreferences.setSubtitlesHideSelected(subsHide.isSelected());
213252

214253
Platform.exit();
215254
}

Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Name: mplayer4anime *
44
* Author: Dmitry Isaenko *
55
* License: GNU GPL v.3 *
6-
* Version: 0.8.4 *
6+
* Version: 0.9 *
77
* Site: https://developersu.blogspot.com/ *
88
* 2018, Russia *
99
***********************************************/

landingPage.fxml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@
6969
</graphic>
7070
</Button>
7171
<Pane HBox.hgrow="ALWAYS" />
72+
<SplitMenuButton mnemonicParsing="false" onAction="#subsTriggerBtn" styleClass="splitMenuButton" stylesheets="@res/landing.css">
73+
<graphic>
74+
<SVGPath content="M 4,18 C 2.8954305,18 2,17.104569 2,16 V 4 C 2,2.89 2.9,2 4,2 h 16 c 1.104569,0 2,0.8954305 2,2 v 12 c 0,1.104569 -0.895431,2 -2,2 m -6,-7 v 1 h 5 V 11 M 5,12 h 8 V 11 H 5 m 0,3 v 1 h 14 v -1 z" fill="#e1e1e1" />
75+
</graphic>
76+
<items>
77+
<CheckMenuItem fx:id="subsHide" mnemonicParsing="false" text="%subsShow_option" />
78+
</items>
79+
</SplitMenuButton>
7280
<SplitMenuButton mnemonicParsing="false" onAction="#fullscreenBtn" styleClass="splitMenuButton" stylesheets="@res/landing.css">
7381
<items>
7482
<CheckMenuItem fx:id="fullScreen" mnemonicParsing="false" text="%fullscreen_option" />

localization/locale_en.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
about_line1=mplayer4amine distributes under GNU GPLv3 license.
2-
about_line2=Release: v0.8.4
2+
about_line2=Release: v0.9
33
about_line3=Development & maintenance by Dmitry Isaenko.
44
about_AboutName=About
55
main_tab_audio=Audio
@@ -24,4 +24,5 @@ settings_LoadListsOnStart=Save & restore previously opened lists after applicati
2424
settings_subsExtensionList=Avaliable subtitles extensions:
2525
settings_subsCodepageList=Avaliable codepages for subtitles:
2626
settings_fieldContainSpacesTabs=Spaces and tab symbols are not allowed.
27+
subsShow_option=Don't show subtitles.
2728

localization/locale_ru.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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.
2-
about_line2=\u0420\u0435\u043B\u0438\u0437: v0.8.4
2+
about_line2=\u0420\u0435\u043B\u0438\u0437: v0.9
33
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.
44
about_AboutName=\u041E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438
55
main_tab_audio=\u0410\u0443\u0434\u0438\u043E
@@ -24,3 +24,4 @@ settings_LoadListsOnStart=\u0417\u0430\u043F\u043E\u043C\u0438\u043D\u0430\u0442
2424
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:
2525
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:
2626
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.
27+
subsShow_option=\u041D\u0435 \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0442\u044C \u0441\u0443\u0431\u0442\u0438\u0442\u0440\u044B.

0 commit comments

Comments
 (0)