Also, if the position is valid, set it to 1 / INF. Windows interprets 0 as non-progress. Progress is quantized into uint8 range, it is good enough for this use-case. This avoids unnecessary vo_control and ITaskbarList3::SetProgressValue calls and should be visually indistinguishable in practice. Fixes #14282
Unified · Split
| @@ -15,10 +15,11 @@ · 14 unmodified lines | ||
| 15 | 15 | * License along with mpv. If not, see <http://www.gnu.org/licenses/>. |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | −#include <stddef.h> | |
| 19 | −#include <stdbool.h> | |
| 20 | −#include <errno.h> | |
| 21 | 18 | #include <assert.h> |
| 19 | +#include <errno.h> | |
| 20 | +#include <math.h> | |
| 21 | +#include <stdbool.h> | |
| 22 | +#include <stddef.h> | |
| 22 | 23 | |
| 23 | 24 | #include "mpv_talloc.h" |
| 24 | 25 | |
| @@ -191,17 +192,18 @@ void update_vo_playback_state(struct MPContext *mpctx) · 166 unmodified lines | ||
| 191 | 192 | { |
| 192 | 193 | if (mpctx->video_out && mpctx->video_out->config_ok) { |
| 193 | 194 | struct voctrl_playback_state oldstate = mpctx->vo_playback_state; |
| 195 | + double pos = get_current_pos_ratio(mpctx, false); | |
| 194 | 196 | struct voctrl_playback_state newstate = { |
| 195 | − .taskbar_progress = mpctx->opts->vo->taskbar_progress, | |
| 197 | + .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0, | |
| 196 | 198 | .playing = mpctx->playing, |
| 197 | 199 | .paused = mpctx->paused, |
| 198 | − .percent_pos = get_percent_pos(mpctx), | |
| 200 | + .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0, | |
| 199 | 201 | }; |
| 200 | 202 | |
| 201 | 203 | if (oldstate.taskbar_progress != newstate.taskbar_progress || |
| 202 | 204 | oldstate.playing != newstate.playing || |
| 203 | 205 | oldstate.paused != newstate.paused || |
| 204 | − oldstate.percent_pos != newstate.percent_pos) | |
| 206 | + oldstate.position != newstate.position) | |
| 205 | 207 | { |
| 206 | 208 | // Don't update progress bar if it was and still is hidden |
| 207 | 209 | if ((oldstate.playing && oldstate.taskbar_progress) || |
| @@ -149,7 +149,7 @@ struct voctrl_playback_state { · 148 unmodified lines | ||
| 149 | 149 | bool taskbar_progress; |
| 150 | 150 | bool playing; |
| 151 | 151 | bool paused; |
| 152 | − int percent_pos; | |
| 152 | + uint8_t position; | |
| 153 | 153 | }; |
| 154 | 154 | |
| 155 | 155 | // VOCTRL_PERFORMANCE_DATA |
| @@ -767,8 +767,15 @@ static void update_playback_state(struct vo_w32_state *w32) · 766 unmodified lines | ||
| 767 | 767 | return; |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | + ULONGLONG completed = pstate->position; | |
| 771 | + ULONGLONG total = UINT8_MAX; | |
| 772 | + if (!pstate->position) { | |
| 773 | + completed = 1; | |
| 774 | + total = MAXULONGLONG; | |
| 775 | + } | |
| 776 | + | |
| 770 | 777 | ITaskbarList3_SetProgressValue(w32->taskbar_list3, w32->window, |
| 771 | − pstate->percent_pos, 100); | |
| 778 | + completed, total); | |
| 772 | 779 | ITaskbarList3_SetProgressState(w32->taskbar_list3, w32->window, |
| 773 | 780 | pstate->paused ? TBPF_PAUSED : |
| 774 | 781 | TBPF_NORMAL); |