This stops decreasing numerical values of --loop-file on each iteration so that loop-file=N loops every playlist entry without having to add --loop-file to --reset-on-next-file. The current behavior confuses users as seen in: https://github.com/mpv-player/mpv/issues/2481 https://github.com/mpv-player/mpv/issues/5943 https://github.com/mpv-player/mpv/issues/11291 https://github.com/mpv-player/mpv/issues/13860 https://www.reddit.com/r/mpv/comments/rcwnrw/looping_each_file_n_times_in_a_playlist/ Also options are supposed to reflect the value configured by the user and not change on their own. A remaining-file-loops property is exposed as a replacement to check how many loops are left.
Unified · Split
| @@ -0,0 +1,2 @@ | |||
| 1 | numerical values of `--loop-file` no longer decrease on each iteration | ||
| 2 | add `remaining-file-loops` property as a replacement to get the remaining loop count | ||
| @@ -2142,6 +2142,12 @@ Property list · 2141 unmodified lines | |||
| 2142 | ``playback-time/full`` | 2142 | ``playback-time/full`` |
| 2143 | ``playback-time`` with milliseconds. | 2143 | ``playback-time`` with milliseconds. |
| 2144 | 2144 | ||
| 2145 | ``remaining-file-loops`` | ||
| 2146 | How many more times the current file is going to be looped. This is | ||
| 2147 | initialized from the value of ``--loop-file``. This counts the number of | ||
| 2148 | times it causes the player to seek to the beginning of the file, so it is 0 | ||
| 2149 | the last the time is played. -1 corresponds to infinity. | ||
| 2150 | |||
| 2145 | ``chapter`` (RW) | 2151 | ``chapter`` (RW) |
| 2146 | Current chapter number. The number of the first chapter is 0. | 2152 | Current chapter number. The number of the first chapter is 0. |
| 2147 | 2153 | ||
| @@ -869,6 +869,13 @@ static int mp_property_playtime_remaining(void *ctx, struct m_property *prop, · 868 unmodified lines | |||
| 869 | return property_time(action, arg, remaining / speed); | 869 | return property_time(action, arg, remaining / speed); |
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | static int mp_property_remaining_file_loops(void *ctx, struct m_property *prop, | ||
| 873 | int action, void *arg) | ||
| 874 | { | ||
| 875 | MPContext *mpctx = ctx; | ||
| 876 | return m_property_int_ro(action, arg, mpctx->remaining_file_loops); | ||
| 877 | } | ||
| 878 | |||
| 872 | /// Current chapter (RW) | 879 | /// Current chapter (RW) |
| 873 | static int mp_property_chapter(void *ctx, struct m_property *prop, | 880 | static int mp_property_chapter(void *ctx, struct m_property *prop, |
| 874 | int action, void *arg) | 881 | int action, void *arg) |
| @@ -3999,7 +4006,7 @@ static const struct m_property mp_properties_base[] = { · 3124 unmodified lines | |||
| 3999 | {"audio-pts", mp_property_audio_pts}, | 4006 | {"audio-pts", mp_property_audio_pts}, |
| 4000 | {"playtime-remaining", mp_property_playtime_remaining}, | 4007 | {"playtime-remaining", mp_property_playtime_remaining}, |
| 4001 | M_PROPERTY_ALIAS("playback-time", "time-pos"), | 4008 | M_PROPERTY_ALIAS("playback-time", "time-pos"), |
| 4002 | {"chapter", mp_property_chapter}, | 4009 | {"remaining-file-loops", mp_property_remaining_file_loops}, |
| 4003 | {"edition", mp_property_edition}, | 4010 | {"edition", mp_property_edition}, |
| 4004 | {"current-edition", mp_property_current_edition}, | 4011 | {"current-edition", mp_property_current_edition}, |
| 4005 | {"chapters", mp_property_chapters}, | 4012 | {"chapters", mp_property_chapters}, |
| @@ -7484,6 +7491,11 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, · 3478 unmodified lines | |||
| 7484 | mpctx->stop_play = PT_CURRENT_ENTRY; | 7491 | mpctx->stop_play = PT_CURRENT_ENTRY; |
| 7485 | } | 7492 | } |
| 7486 | 7493 | ||
| 7494 | if (opt_ptr == &opts->loop_file) { | ||
| 7495 | mpctx->remaining_file_loops = opts->loop_file; | ||
| 7496 | mp_notify_property(mpctx, "remaining-file-loops"); | ||
| 7497 | } | ||
| 7498 | |||
| 7487 | if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1]) { | 7499 | if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1]) { |
| 7488 | update_ab_loop_clip(mpctx); | 7500 | update_ab_loop_clip(mpctx); |
| 7489 | // Update if visible | 7501 | // Update if visible |
| @@ -421,6 +421,8 @@ typedef struct MPContext { · 420 unmodified lines | |||
| 421 | int max_frames; | 421 | int max_frames; |
| 422 | bool playing_msg_shown; | 422 | bool playing_msg_shown; |
| 423 | 423 | ||
| 424 | int remaining_file_loops; | ||
| 425 | |||
| 424 | bool paused_for_cache; | 426 | bool paused_for_cache; |
| 425 | bool demux_underrun; | 427 | bool demux_underrun; |
| 426 | double cache_stop_time; | 428 | double cache_stop_time; |
| @@ -1633,6 +1633,9 @@ static void play_current_file(struct MPContext *mpctx) · 1632 unmodified lines | |||
| 1633 | load_per_file_options(mpctx->mconfig, mpctx->playing->params, | 1633 | load_per_file_options(mpctx->mconfig, mpctx->playing->params, |
| 1634 | mpctx->playing->num_params); | 1634 | mpctx->playing->num_params); |
| 1635 | 1635 | ||
| 1636 | mpctx->remaining_file_loops = mpctx->opts->loop_file; | ||
| 1637 | mp_notify_property(mpctx, "remaining-file-loops"); | ||
| 1638 | |||
| 1636 | mpctx->max_frames = opts->play_frames; | 1639 | mpctx->max_frames = opts->play_frames; |
| 1637 | 1640 | ||
| 1638 | handle_force_window(mpctx, false); | 1641 | handle_force_window(mpctx, false); |
| @@ -901,10 +901,10 @@ static void handle_loop_file(struct MPContext *mpctx) · 900 unmodified lines | |||
| 901 | } | 901 | } |
| 902 | target = ab[0]; | 902 | target = ab[0]; |
| 903 | prec = MPSEEK_EXACT; | 903 | prec = MPSEEK_EXACT; |
| 904 | } else if (opts->loop_file) { | 904 | } else if (mpctx->remaining_file_loops) { |
| 905 | if (opts->loop_file > 0) { | 905 | if (mpctx->remaining_file_loops > 0) { |
| 906 | opts->loop_file--; | 906 | mpctx->remaining_file_loops--; |
| 907 | m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->loop_file); | 907 | mp_notify_property(mpctx, "remaining-file-loops"); |
| 908 | } | 908 | } |
| 909 | target = get_start_time(mpctx, mpctx->play_dir); | 909 | target = get_start_time(mpctx, mpctx->play_dir); |
| 910 | } | 910 | } |