@@ -38,6 +38,9 @@ public class Controller implements Initializable {
38
38
@ FXML
39
39
private TabPane tabPane ;
40
40
41
+ @ FXML
42
+ private CheckMenuItem subsHide ;
43
+
41
44
@ Override
42
45
public void initialize (URL url , ResourceBundle rb ) {
43
46
// Register this controller in mediator
@@ -80,6 +83,7 @@ public void initialize(URL url, ResourceBundle rb) {
80
83
}
81
84
}
82
85
fullScreen .setSelected (appPreferences .getFullScreenSelected ());
86
+ subsHide .setSelected (appPreferences .getSubtitlesHideSelected ());
83
87
}
84
88
85
89
public void setHostServices (HostServices hostServices ) {
@@ -96,6 +100,31 @@ private boolean playerSingleCommand(String command){
96
100
return true ;
97
101
} else { return false ; }
98
102
}
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
+ }
99
128
@ FXML
100
129
private void fullscreenBtn (){ playerSingleCommand ("vo_fullscreen" ); }
101
130
@ FXML
@@ -148,6 +177,7 @@ private void playBtn(){
148
177
"-quiet" ,
149
178
fullScreen .isSelected () ? "-fs" : "" ,
150
179
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)
151
181
Subtitles ?"-sub" :"" ,
152
182
Subtitles ? subPaneController .paneFileList .get (mkvPaneController .paneListView .getSelectionModel ().getSelectedIndex ()).toPath ().toString ():"" ,
153
183
Subtitles ?SubCodepageDefault ?"" :"-subcp" :"" , // Use subtitles -> YES -> Check if we need codepage
@@ -163,6 +193,14 @@ private void playBtn(){
163
193
new LineRedirecter (player .getErrorStream (), writeTo ).start ();
164
194
165
195
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
+
166
204
} else {
167
205
playerIn .print ("pause" );
168
206
playerIn .print ("\n " );
@@ -210,6 +248,7 @@ public void shutdown(){
210
248
appPreferences .setLastTimeUsedSusExt (subPaneController .subtExt .getValue ());
211
249
appPreferences .setLastTimeUsedSubsCodepage (subPaneController .subtCodepage .getValue ());
212
250
appPreferences .setFullScreenSelected (fullScreen .isSelected ());
251
+ appPreferences .setSubtitlesHideSelected (subsHide .isSelected ());
213
252
214
253
Platform .exit ();
215
254
}
0 commit comments