summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/player/command.c b/player/command.c
index 77645d3755..8887338a6e 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3682,6 +3682,18 @@ static int mp_property_multiply(char *property, double f, struct MPContext *mpct
return r;
}
+static struct track *find_track_with_url(struct MPContext *mpctx, int type,
+ const char *url)
+{
+ for (int n = 0; n < mpctx->num_tracks; n++) {
+ struct track *track = mpctx->tracks[n];
+ if (track && track->type == type && track->is_external &&
+ strcmp(track->external_filename, url) == 0)
+ return track;
+ }
+ return NULL;
+}
+
// Whether this property should react to key events generated by auto-repeat.
static bool check_property_autorepeat(char *property, struct MPContext *mpctx)
{
@@ -4090,10 +4102,19 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_SUB_ADD: {
if (!mpctx->playing)
return -1;
+ if (cmd->args[1].v.i == 2) {
+ struct track *sub = find_track_with_url(mpctx, STREAM_SUB,
+ cmd->args[0].v.s);
+ if (sub) {
+ mp_switch_track(mpctx, sub->type, sub);
+ mp_mark_user_track_selection(mpctx, 0, sub->type);
+ return 0;
+ }
+ }
struct track *sub = mp_add_subtitles(mpctx, cmd->args[0].v.s);
if (!sub)
return -1;
- if (cmd->args[1].v.i == 0) {
+ if (cmd->args[1].v.i != 1) {
mp_switch_track(mpctx, sub->type, sub);
mp_mark_user_track_selection(mpctx, 0, sub->type);
}