Skip to content

fix(player): 记忆桌面端播放器音量,避免每次打开视频都重置为最大#2273

Closed
liangyuR wants to merge 32 commits into
Predidit:mainfrom
liangyuR:cursor/persist-desktop-volume-upstream-a1ea
Closed

fix(player): 记忆桌面端播放器音量,避免每次打开视频都重置为最大#2273
liangyuR wants to merge 32 commits into
Predidit:mainfrom
liangyuR:cursor/persist-desktop-volume-upstream-a1ea

Conversation

@liangyuR

Copy link
Copy Markdown
Contributor

问题

Windows/桌面端每次打开视频音量都重置为最大(100)。原因:桌面端音量是 media_kit (mpv) 的应用内音量,从未持久化PlayerController 按视频路由注册为 singleton,离开视频页后销毁,下次打开是全新实例,volume 回到哨兵值 -1,init 时被硬编码为 100

修复

  • lib/services/storage/settings_keys.dart 新增持久化设置 defaultVolumedouble,默认 100.0,分组 player),并加入 all 注册列表。
  • PlayerController.init() 桌面分支用 GStorage.getSetting(SettingsKeys.defaultVolume) 替代硬编码 100,恢复上次音量。
  • 桌面端音量变更(滚轮/快捷键经 setVolume、手势经 finishVolumeGesture)后写回存储,仅在取整值变化时写入以避免冗余写。
  • 移动端音量走系统音量,逻辑完全不变。

测试

  • flutter analyze --no-fatal-infos --fatal-warnings(无 warning/error,仅既有 info 级 lint)
  • flutter test test/settings_default_volume_test.dart(验证新设置默认值、分组、注册、持久化键名)

liangyuR and others added 24 commits June 23, 2026 21:37
Co-authored-by: 文质彬彬的大锤 <liangyuR@users.noreply.github.com>
Co-authored-by: 文质彬彬的大锤 <liangyuR@users.noreply.github.com>
Document the five-PR rollout for pageUrl-based episode identity, including PR2 EpisodeRef scope and acceptance criteria.

Co-authored-by: Cursor <cursoragent@cursor.com>
- 引入 EpisodeRef 承载播放集数页地址和排序号

- 播放切集与媒体队列复用统一集数解析结果

- 更新 EpisodeRef 单元测试
- 在 PlaybackInitParams 中引入 sortNumber,用作剧集排序参考。
- 更新 EpisodeRef,新增 sortNumber,并补充在线与离线上下文中的详细解析说明。
- 合并 codex/refactor-episode-ref-upstream,为 PR3 历史 pageUrl 主键改造准备基础。
Co-authored-by: 文质彬彬的大锤 <liangyuR@users.noreply.github.com>
fix(player): 记忆桌面端播放器音量
Co-authored-by: 文质彬彬的大锤 <liangyuR@users.noreply.github.com>
Set up Cursor Cloud dev environment for Kazumi
@kilo-code-bot

kilo-code-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

This increment merges the "unified episode identity" work into the branch: history progress is now matched by episodePageUrl (with legacy episode-index fallback and synthetic-bucket allocation) so that progress survives source/episode reordering, plus the ResolvedEpisodeEpisodeRef rename and sortNumber/pageUrl plumbing.

The _HistoryEpisodeMatcher logic is internally consistent between history_sync.dart and history_repository.dart, the resume path in video_page.dart correctly prioritizes page-URL matching with a bounded fallback to the stored road/episode, and the behavior is extensively covered by new tests (page-url collisions, synthetic buckets, backfill, legacy fallback, codec round-trips). No high-confidence issues were found in the PR-changed lines.

Note: lib/pages/player/player_item.dart and player_models.dart appear in the raw multi-commit patch but are not part of the PR's net diff (already present in the base), so they were treated as out of scope.

Files Reviewed (changed code)
  • lib/modules/history/history_sync.dart
  • lib/repositories/history_repository.dart
  • lib/pages/video/video_controller.dart
  • lib/pages/video/video_page.dart
  • lib/pages/history/history_controller.dart
  • lib/services/sync/history_sync_service.dart
  • lib/modules/history/history_module.dart
  • test/history_repository_test.dart
  • test/history_sync_test.dart
  • test/episode_ref_test.dart
Previous Review Summaries (2 snapshots, latest commit c7ab691)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c7ab691)

Status: No Issues Found | Recommendation: Merge

The latest commits only remove two explanatory comments in _persistDesktopVolume and delete the settings_default_volume_test.dart test file. The core fix (persisting desktop player volume via defaultVolume, clamping to 0.0..100.0, gating on isDesktop(), and avoiding redundant writes) is unchanged and remains correct. No functional code changes were introduced in this increment.

Note: deleting test/settings_default_volume_test.dart removes coverage for the defaultVolume setting; consider keeping it. This is advisory only and not a blocker.

Files Reviewed (2 files)
  • lib/pages/player/player_controller.dart
  • test/settings_default_volume_test.dart (deleted)

Previous review (commit 0733b0b)

Status: No Issues Found | Recommendation: Merge

The fix is well-scoped: desktop player volume is now persisted via the new defaultVolume setting and restored on init() instead of resetting to 100. Persistence is correctly gated behind isDesktop(), values are clamped to 0.0..100.0, and redundant writes are avoided by comparing rounded values. Mobile (system-volume) behavior is unchanged.

Files Reviewed (3 files)
  • lib/pages/player/player_controller.dart
  • lib/services/storage/settings_keys.dart
  • test/settings_default_volume_test.dart

Reviewed by claude-4.8-opus-20260528 · Input: 4.5K · Output: 25.2K · Cached: 1.3M

liangyuR and others added 5 commits June 26, 2026 21:21
- 合并 upstream/main 至 fork main

- 保留 fork-only 文档与本地测试补充
- 为单条 Progress 记录 episodePageUrl 并优先按 URL 匹配

- 兼容旧集数进度并在查询、更新、同步路径懒回填 URL

- 增加历史仓储、同步和播放恢复定位测试
@Predidit

Copy link
Copy Markdown
Owner

移除注释,这里的注释过于显而易见

移除测试,此测试本质在测试 hive 存储可靠性,没有必要

cursoragent and others added 3 commits June 27, 2026 01:43
Co-authored-by: 文质彬彬的大锤 <liangyuR@users.noreply.github.com>
### Refactor:按页面 URL 区分历史进度
…p-volume-upstream-a1ea

# Conflicts:
#	lib/pages/player/player_controller.dart

Co-authored-by: 文质彬彬的大锤 <liangyuR@users.noreply.github.com>
@liangyuR liangyuR closed this Jun 27, 2026
@liangyuR liangyuR deleted the cursor/persist-desktop-volume-upstream-a1ea branch June 27, 2026 05:51
@liangyuR liangyuR restored the cursor/persist-desktop-volume-upstream-a1ea branch June 27, 2026 05:52
@liangyuR liangyuR reopened this Jun 27, 2026
@liangyuR liangyuR closed this Jun 27, 2026
@liangyuR liangyuR deleted the cursor/persist-desktop-volume-upstream-a1ea branch June 27, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants