Skip to content

Commit

Permalink
Added command line option to hide subtitles.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjfwalsh committed May 2, 2019
1 parent f06235c commit 5a6f8c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Usage: omxplayer [OPTIONS] [FILE]
--no-osd Do not display status information on screen
--no-keys Disable keyboard input (prevents hangs for certain TTYs)
--subtitles path External subtitles in UTF-8 srt format
--hide-subtitles Hide subtitles (shown by default if found)
--font path Default: /usr/share/fonts/truetype/freefont/FreeSans.ttf
--italic-font path Default: /usr/share/fonts/truetype/freefont/FreeSansOblique.ttf
--font-size size Font size in 1/1000 screen height (default: 55)
Expand Down
9 changes: 8 additions & 1 deletion omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ long m_Amplification = 0;
bool m_NativeDeinterlace = false;
bool m_HWDecode = false;
bool m_osd = true;
bool m_show_subtitles = true;
bool m_no_keys = false;
std::string m_external_subtitles_path;
bool m_has_external_subtitles = false;
Expand Down Expand Up @@ -550,6 +551,7 @@ int main(int argc, char *argv[])
const int key_config_opt = 0x10d;
const int amp_opt = 0x10e;
const int no_osd_opt = 0x202;
const int hide_subtitles_opt= 0x214;
const int orientation_opt = 0x204;
const int fps_opt = 0x208;
const int live_opt = 0x205;
Expand Down Expand Up @@ -617,6 +619,7 @@ int main(int argc, char *argv[])
{ "no-boost-on-downmix", no_argument, NULL, no_boost_on_downmix_opt },
{ "key-config", required_argument, NULL, key_config_opt },
{ "no-osd", no_argument, NULL, no_osd_opt },
{ "hide-subtitles", no_argument, NULL, hide_subtitles_opt },
{ "no-keys", no_argument, NULL, no_keys_opt },
{ "orientation", required_argument, NULL, orientation_opt },
{ "fps", required_argument, NULL, fps_opt },
Expand Down Expand Up @@ -762,6 +765,9 @@ int main(int argc, char *argv[])
case no_osd_opt:
m_osd = false;
break;
case hide_subtitles_opt:
m_show_subtitles = false;
break;
case no_keys_opt:
m_no_keys = true;
break;
Expand Down Expand Up @@ -1138,7 +1144,7 @@ int main(int argc, char *argv[])
m_player_subtitles.SetUseExternalSubtitles(false);
}

if(m_subtitle_index == -1 && !m_has_external_subtitles)
if(!m_show_subtitles || (m_subtitle_index == -1 && !m_has_external_subtitles))
m_player_subtitles.SetVisible(false);
}

Expand Down Expand Up @@ -1205,6 +1211,7 @@ int main(int argc, char *argv[])
case KeyConfig::ACTION_CHANGE_FILE:
FlushStreams(DVD_NOPTS_VALUE);
m_omx_reader.Close();
m_show_subtitles = m_player_subtitles.GetVisible(); // current pref
m_player_subtitles.Close();
m_player_video.Close();
m_player_audio.Close();
Expand Down

0 comments on commit 5a6f8c2

Please sign in to comment.