fix(player): 记忆桌面端播放器音量#2278
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Code Review SummaryStatus: No Issues Found | Recommendation: Merge This incremental review covers the new desktop mute feature added since the previous review. Files Reviewed (3 files)
Previous Review Summaries (2 snapshots, latest commit b787532)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit b787532)Status: No Issues Found | Recommendation: Merge The change persists the desktop player volume via the new Files Reviewed (2 files)
Previous review (commit f0ef8f9)Status: No Issues Found | Recommendation: Merge The change cleanly persists the desktop player volume via a new Files Reviewed (3 files)
Reviewed by claude-4.8-opus-20260528 · Input: 3.3K · Output: 7.8K · Cached: 327.8K |
|
这个功能叠加静音快捷键 M 使用时的行为有些奇怪 静音状态没有持久化,这样在重启之后,静音前的音量丢失,使用 M 将不能恢复静音,只能重新调剂音量 |
|
那么 保存静音 状态来解决这个问题? 我看到静音的实现是存了 lastX,然后将音量设置为 0 |
|
除了持久化静音状态,也应该持久化静音前的音量 |
Co-authored-by: 文质彬彬的大锤 <liangyuR@users.noreply.github.com>
问题
桌面端每次打开视频时,播放器音量都会重置为最大(100),不会记住上次的设置。
方案
SettingsKeys.defaultVolume(double,默认100.0,归属SettingGroup.player),用于持久化桌面端音量。PlayerController中新增_persistDesktopVolume(),在setVolume及音量初始化时把当前音量写入设置(仅桌面端,做范围裁剪与去抖,避免重复写入)。init()中桌面端默认音量由硬编码100改为读取SettingsKeys.defaultVolume,从而在会话之间记忆音量。测试
test/settings_default_volume_test.dart单元测试,覆盖默认值、分组、全局注册与持久化键名。flutter analyze --no-fatal-infos --fatal-warnings:无问题。flutter test test/settings_default_volume_test.dart:全部通过。