setCache method
Sets the cache configuration atomically.
Writes the six backing mpv properties (cache, cache-secs,
cache-on-disk, cache-pause, cache-pause-wait, cache-pause-initial)
in one shot. Modify a single field via
await player.setCache(state.cache.copyWith(secs: const Duration(seconds: 30))).
During a live PcmSource entry, which plays with cache-pause off,
a new pause holds only until that entry ends.
Implementation
Future<void> setCache(CacheSettings settings) async {
await _gate();
final previous = state.settings.cache;
final writes = <(String, String, String)>[
('cache', settings.mode.mpvValue, previous.mode.mpvValue),
(
'cache-secs',
durationToSeconds(settings.secs).toStringAsFixed(6),
durationToSeconds(previous.secs).toStringAsFixed(6),
),
(
'cache-on-disk',
settings.onDisk ? 'yes' : 'no',
previous.onDisk ? 'yes' : 'no',
),
(
'cache-pause',
settings.pause ? 'yes' : 'no',
previous.pause ? 'yes' : 'no',
),
(
'cache-pause-wait',
durationToSeconds(settings.pauseWait).toStringAsFixed(6),
durationToSeconds(previous.pauseWait).toStringAsFixed(6),
),
(
'cache-pause-initial',
settings.pauseInitial ? 'yes' : 'no',
previous.pauseInitial ? 'yes' : 'no',
),
];
await _calls.writeBundle(
writes,
(v) => _updateField((s) => s.copyWith(cache: v), _reactives.cache, v),
settings,
previous,
);
}