summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-08 21:46:42 +0100
committerwm4 <wm4@nowhere>2014-01-08 21:46:42 +0100
commit1d2a11133737802baa555dcbff9482bd5c8120ad (patch)
treec8c512a911c936435d1201277033793dc48876ff /player/loadfile.c
parent59c6fa220158794791b5e1674c4aa1e1a439c2c8 (diff)
downloadmpv-1d2a11133737802baa555dcbff9482bd5c8120ad.tar.bz2
mpv-1d2a11133737802baa555dcbff9482bd5c8120ad.tar.xz
player: strip 'file://' from filenames on playback start
This fixes two things: 1. Dropping files on the VO window will auto-load subtitles (since most drag & drop code prefixes the filenames with 'file://', and the subtitle auto-load code considers 'file://' non-local) 2. Fix behavior of the %x screenshot filename template (similar problem) One could force all that code to special-case 'file://' URLs, but just replacing the filename on playback start is simpler.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 2189bc4130..e7a45e014d 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1029,6 +1029,7 @@ static void load_per_file_options(m_config_t *conf,
static void play_current_file(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
+ void *tmp = talloc_new(NULL);
double playback_start = -1e100;
mpctx->initialized_flags |= INITIALIZED_PLAYBACK;
@@ -1047,6 +1048,10 @@ static void play_current_file(struct MPContext *mpctx)
if (!mpctx->filename)
goto terminate_playback;
+ char *local_filename = mp_file_url_to_filename(tmp, bstr0(mpctx->filename));
+ if (local_filename)
+ mpctx->filename = local_filename;
+
#if HAVE_ENCODING
encode_lavc_discontinuity(mpctx->encode_lavc_ctx);
#endif
@@ -1096,6 +1101,7 @@ static void play_current_file(struct MPContext *mpctx)
char *stream_filename = mpctx->filename;
mpctx->resolve_result = resolve_url(stream_filename, mpctx->global);
if (mpctx->resolve_result) {
+ talloc_steal(tmp, mpctx->resolve_result);
print_resolve_contents(mpctx->log, mpctx->resolve_result);
if (mpctx->resolve_result->playlist) {
transfer_playlist(mpctx, mpctx->resolve_result->playlist);
@@ -1370,8 +1376,8 @@ terminate_playback: // don't jump here after ao/vo/getch initialization!
getch2_enable();
mpctx->filename = NULL;
- talloc_free(mpctx->resolve_result);
mpctx->resolve_result = NULL;
+ talloc_free(tmp);
// Played/paused for longer than 3 seconds -> ok
bool playback_short = mpctx->stop_play == AT_END_OF_FILE &&