diff options
-rw-r--r-- | DOCS/tech/slave.txt | 8 | ||||
-rw-r--r-- | help/help_mp-en.h | 1 | ||||
-rw-r--r-- | input/input.c | 2 | ||||
-rw-r--r-- | input/input.h | 2 | ||||
-rw-r--r-- | mplayer.c | 64 |
5 files changed, 77 insertions, 0 deletions
diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt index 06274f5e2e..5098d3ac80 100644 --- a/DOCS/tech/slave.txt +++ b/DOCS/tech/slave.txt @@ -76,6 +76,14 @@ sub_step <value> Step forward in the subtitle list by <value> steps or backwards if <value> is negative. +sub_load <subtitle_file> + Loads subtitles from <subtitle_file>. + +sub_remove [<value>] + If the <value> argument is present and non-negative, removes the subtitle + file with index <value>. If the argument is omitted or negative, removes + all subtitle files. + osd [<level>] Toggle OSD mode or set it to level when <level> >= 0. diff --git a/help/help_mp-en.h b/help/help_mp-en.h index 67f064c96b..2bba485957 100644 --- a/help/help_mp-en.h +++ b/help/help_mp-en.h @@ -152,6 +152,7 @@ static char help_text[]= " won't help unless you provide this information when reporting a possible bug.\n" #define MSGTR_LoadingConfig "Loading config '%s'\n" #define MSGTR_AddedSubtitleFile "SUB: added subtitle file (%d): %s\n" +#define MSGTR_RemovedSubtitleFile "SUB: removed subtitle file (%d): %s\n" #define MSGTR_ErrorOpeningOutputFile "Error opening file [%s] for writing!\n" #define MSGTR_CommandLine "CommandLine:" #define MSGTR_RTCDeviceNotOpenable "Failed to open %s: %s (it should be readable by the user.)\n" diff --git a/input/input.c b/input/input.c index 3a9456566d..04b7bff576 100644 --- a/input/input.c +++ b/input/input.c @@ -77,6 +77,8 @@ static mp_cmd_t mp_cmds[] = { { MP_CMD_SUB_POS, "sub_pos", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, { MP_CMD_SUB_ALIGNMENT, "sub_alignment",0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, { MP_CMD_SUB_VISIBILITY, "sub_visibility", 0, { {-1,{0}} } }, + { MP_CMD_SUB_LOAD, "sub_load", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, + { MP_CMD_SUB_REMOVE, "sub_remove", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, { MP_CMD_SUB_SELECT, "vobsub_lang", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, // for compatibility { MP_CMD_SUB_SELECT, "sub_select", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, { MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } }, diff --git a/input/input.h b/input/input.h index 72f3ff07f6..43ea58d69e 100644 --- a/input/input.h +++ b/input/input.h @@ -65,6 +65,8 @@ #define MP_CMD_SUB_LOG 61 #define MP_CMD_SWITCH_AUDIO 62 #define MP_CMD_GET_TIME_POS 63 +#define MP_CMD_SUB_LOAD 64 +#define MP_CMD_SUB_REMOVE 65 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001 @@ -3378,6 +3378,70 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still) } #endif } break; + case MP_CMD_SUB_LOAD: + { +#ifdef USE_SUB + if (sh_video) { + int n = set_of_sub_size; + add_subtitles(cmd->args[0].v.s, sh_video->fps, 0); + if (n != set_of_sub_size) { + if (global_sub_indices[SUB_SOURCE_SUBS] < 0) + global_sub_indices[SUB_SOURCE_SUBS] = global_sub_size; + ++global_sub_size; + } + } +#endif + } break; + case MP_CMD_SUB_REMOVE: + { +#ifdef USE_SUB + if (sh_video) { + int v = cmd->args[0].v.i; + sub_data *subd; + if (v < 0) { + for (v = 0; v < set_of_sub_size; ++v) { + subd = set_of_subtitles[v]; + mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename); + sub_free(subd); + set_of_subtitles[v] = NULL; + } + global_sub_indices[SUB_SOURCE_SUBS] = -1; + global_sub_size -= set_of_sub_size; + set_of_sub_size = 0; + if (set_of_sub_pos >= 0) { + global_sub_pos = -2; + vo_sub_last = vo_sub = NULL; + vo_osd_changed(OSDTYPE_SUBTITLE); + vo_update_osd(sh_video->disp_w, sh_video->disp_h); + mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); + } + } + else if (v < set_of_sub_size) { + subd = set_of_subtitles[v]; + mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename); + sub_free(subd); + if (set_of_sub_pos == v) { + global_sub_pos = -2; + vo_sub_last = vo_sub = NULL; + vo_osd_changed(OSDTYPE_SUBTITLE); + vo_update_osd(sh_video->disp_w, sh_video->disp_h); + mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); + } + else if (set_of_sub_pos > v) { + --set_of_sub_pos; + --global_sub_pos; + } + while (++v < set_of_sub_size) + set_of_subtitles[v - 1] = set_of_subtitles[v]; + --set_of_sub_size; + --global_sub_size; + if (set_of_sub_size <= 0) + global_sub_indices[SUB_SOURCE_SUBS] = -1; + set_of_subtitles[set_of_sub_size] = NULL; + } + } +#endif + } break; case MP_CMD_GET_SUB_VISIBILITY: { #ifdef USE_SUB |