diff options
author | wm4 <wm4@nowhere> | 2014-01-04 01:27:06 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-01-04 01:27:29 +0100 |
commit | 7041d8cd3735c3832cc2ce7ed62467c25c37f511 (patch) | |
tree | 2c088883095c7de541e2e82184938a667df22e62 /video/out/vo.c | |
parent | 6a1b12158d903c09b7889820451b07dc73ee8576 (diff) | |
download | mpv-7041d8cd3735c3832cc2ce7ed62467c25c37f511.tar.bz2 mpv-7041d8cd3735c3832cc2ce7ed62467c25c37f511.tar.xz |
vo: dropping subtitle files on the VO window adds them as subtitle files
Note that we don't try to be clever about detecting the files as
subtitles: we just check the file extension. We could go all the way and
check the files by opening them with a demuxer, but that would probably
do more bad than good.
Diffstat (limited to 'video/out/vo.c')
-rw-r--r-- | video/out/vo.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index 689b6b6da1..68fb7d0ee7 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -43,6 +43,7 @@ #include "video/mp_image.h" #include "video/vfcap.h" #include "sub/osd.h" +#include "sub/find_subfiles.h" // // Externally visible list of all vo drivers @@ -631,16 +632,31 @@ static void run_cmd(struct vo *vo, const char **cmd) // Handle drag & drop event of a list of files on the VO window. void vo_drop_files(struct vo *vo, int num_files, char **files) { - for (int i = 0; i < num_files; i++) { - const char *cmd[] = { - "loadfile", - files[i], - /* Start playing the dropped files right away */ - (i == 0) ? "replace" : "append", - NULL - }; - - MP_VERBOSE(vo, "received dropped file: %s\n", files[i]); - run_cmd(vo, cmd); + bool all_sub = true; + for (int i = 0; i < num_files; i++) + all_sub &= mp_might_be_subtitle_file(files[i]); + + if (all_sub) { + for (int i = 0; i < num_files; i++) { + const char *cmd[] = { + "sub_add", + files[i], + NULL + }; + run_cmd(vo, cmd); + } + } else { + for (int i = 0; i < num_files; i++) { + const char *cmd[] = { + "loadfile", + files[i], + /* Start playing the dropped files right away */ + (i == 0) ? "replace" : "append", + NULL + }; + + MP_VERBOSE(vo, "received dropped file: %s\n", files[i]); + run_cmd(vo, cmd); + } } } |