History

player: don't force saving start in watch-later-options

The watch-later mechanism has always unconditionally wrote start to files to save the playback position. When this was later expanded to watch-later-options, this logic was kept in place. But we don't actually have to unconditionally write this and can allow users to remove the option from the list if they want to. The start value still requires some special handling; it should always be written if possible regardless of the value changing. However, we can just place it within the default set of options for watch-later-options so it can be removed like any other.

Dudemanguy committed 3 years ago

Commit 6471afe1 parent c4ec47a4 files · +15 −6Browse files

Unified · Split

4 files
  1. DOCS/interface-changes.rst +4 −0
  2. DOCS/man/options.rst +3 −4
  3. options/options.c +1 −0
  4. player/configfiles.c +7 −2
DOCS/interface-changes.rst+4−0
@@ -41,6 +41,10 @@ Interface changes · 40 unmodified lines
4141 - deprecate `--drm-atomic`
4242 - add `--demuxer-hysteresis-secs`
4343 - add `--video-sync=display-tempo`
44+ - the `start` option is no longer unconditionally written by
45+ watch-later. It is still written by default but you may
46+ need to explictly add `start` depending on how you have
47+ `--watch-later-options` configured.
4448 --- mpv 0.35.0 ---
4549 - add the `--vo=gpu-next` video output driver, as well as the options
4650 `--allow-delayed-peak-detect`, `--builtin-scalers`,
DOCS/man/options.rst+3−4
@@ -1032,8 +1032,8 @@ Watch Later · 1031 unmodified lines
10321032 ``--watch-later-options=option1,option2,...``
10331033 The options that are saved in "watch later" files if they have been changed
10341034 since when mpv started. These values will be restored the next time the
1035− files are played. The playback position is always saved as ``start``, so
1036− adding ``start`` to this list has no effect.
1035+ files are played. Note that the playback position is saved via the ``start``
1036+ option.
10371037
10381038 When removing options, existing watch later data won't be modified and will
10391039 still be applied fully, but new watch later data won't contain these
@@ -1049,8 +1049,7 @@ Watch Later · 9 unmodified lines
10491049 ``--watch-later-options-remove=mute``
10501050 The volume and mute state won't be saved to watch later files.
10511051 - ``--watch-later-options-clr``
1052− No option will be saved to watch later files except the starting
1053− position.
1052+ No option will be saved to watch later files.
10541053
10551054 ``--write-filename-in-watch-later-config``
10561055 Prepend the watch later config files with the name of the file they refer
options/options.c+1−0
@@ -1069,6 +1069,7 @@ static const struct MPOpts mp_default_opts = { · 1068 unmodified lines
10691069 .cuda_device = -1,
10701070
10711071 .watch_later_options = (char **)(const char*[]){
1072+ "start",
10721073 "osd-level",
10731074 "speed",
10741075 "edition",
player/configfiles.c+7−2
@@ -303,18 +303,23 @@ void mp_write_watch_later_conf(struct MPContext *mpctx) · 302 unmodified lines
303303
304304 write_filename(mpctx, file, cur->filename);
305305
306+ bool write_start = true;
306307 double pos = get_current_time(mpctx);
307308
308309 if ((demux && (!demux->seekable || demux->partially_seekable)) ||
309310 pos == MP_NOPTS_VALUE)
310311 {
312+ write_start = false;
311313 MP_INFO(mpctx, "Not seekable, or time unknown - not saving position.\n");
312− } else {
313− fprintf(file, "start=%f\n", pos);
314314 }
315315 char **watch_later_options = mpctx->opts->watch_later_options;
316316 for (int i = 0; watch_later_options && watch_later_options[i]; i++) {
317317 char *pname = watch_later_options[i];
318+ // Always save start if we have it in the array.
319+ if (write_start && strcmp(pname, "start") == 0) {
320+ fprintf(file, "%s=%f\n", pname, pos);
321+ continue;
322+ }
318323 // Only store it if it's different from the initial value.
319324 if (m_config_watch_later_backup_opt_changed(mpctx->mconfig, pname)) {
320325 char *val = NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t