From 1d2a11133737802baa555dcbff9482bd5c8120ad Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 8 Jan 2014 21:46:42 +0100 Subject: 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. --- player/loadfile.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'player/loadfile.c') 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 && -- cgit v1.2.3