Open
Conversation
test(video-player): 添加 MediaProgressSliderState 单元测试 - 解决播放器实际位置滞后导致的进度条回跳 - 新增 isSeeking 状态与 targetPositionMillis 记录目标 - 在 seek 完成前强制 UI 显示目标位置而非实际位置 - 添加轮询检测机制,当位置误差小于 500ms 时结束 seeking - 测试基本的拖动操作与状态同步 - 测试快速连续拖动时的状态更新逻辑 - 测试 seek 完成的判定条件及误差范围 - 测试预览比例为 NaN 时的边界情况
- 增加 `isPreviewing` 状态断言,验证预览期间及结束后的状态 - 模拟播放器位置追赶过程,确保未到达目标时保持预览状态 - 调用 `checkSeekingComplete` 验证到达目标后状态正确切换 - 移除未使用的 `mutableStateOf` 导入
Author
|
补充了单元测试验证 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题原因
这个问题的根本原因是 异步操作导致的竞态条件 :
快速拖动的问题 :
解决方案
引入"Seeking 状态"来保持进度条显示的一致性:
修改效果
修改前:
拖动进度条到 2:00 → 松开手指 → 进度条瞬间跳回 1:00 → 等待 → 进度条跳到 2:00
快速拖动 A→B → 进度条可能短暂跳回 A 点
修改后:
拖动进度条到 2:00 → 松开手指 → 进度条保持显示 2:00 → 播放器位置到达 2:00 → 正常播放
快速拖动 A→B → 进度条保持显示 B 点,不会跳回 A