up
This commit is contained in:
@@ -3,8 +3,9 @@ class AppConfig {
|
||||
AppConfig._();
|
||||
|
||||
/// App 版本(对应 pubspec version 的 name 部分;version_code 对应 build 号)
|
||||
static const String appVersion = '1.1.0';
|
||||
static const int appVersionCode = 2;
|
||||
/// ⚠️ 每次发版必须与 pubspec.yaml 的 version 同步递增,否则老用户会一直提示更新
|
||||
static const String appVersion = '1.1.7';
|
||||
static const int appVersionCode = 9;
|
||||
|
||||
/// 平台标识(运行时按 iOS/Android 判定,见 platformName)
|
||||
static const String platformNameIOS = 'ios';
|
||||
|
||||
@@ -66,25 +66,33 @@ class FeedPlayerPool {
|
||||
|
||||
/// 绑定窗口:index 为当前页;items 为已解析好播放地址的窗口数据源
|
||||
Future<void> bindWindow(int index, List<({int videoId, String url})> items) async {
|
||||
// 1. 先把**所有**出窗/旧槽位强制停掉(不保留任何正在播放的声音)
|
||||
// 只允许窗口内 [index-1, index, index+1] 这 3 个槽位持有资源
|
||||
// 1. 先切换当前页指针(currentSlot / isCurrentPlaying / 完成回调都依赖它)
|
||||
_currentIndex = index;
|
||||
|
||||
// 窗口内应保留的槽位集合 [index-1, index, index+1]
|
||||
final activeSet = <int>{};
|
||||
for (var offset = -1; offset <= 1; offset++) {
|
||||
final i = index + offset;
|
||||
if (i >= 0 && i < items.length) activeSet.add(slotOf(i));
|
||||
}
|
||||
|
||||
// 2. 立即静音(同步执行,不等后续网络 open):
|
||||
// - 出窗槽位:stop(断音 + 清缓存),并复位
|
||||
// - 窗口内槽位:全部 pause(含刚划走的上一页,防止切页期间串音)
|
||||
// 这一步必须早于任何 await,否则 open 新视频期间旧视频仍在出声
|
||||
for (var s = 0; s < slotCount; s++) {
|
||||
if (activeSet.contains(s)) continue;
|
||||
final slot = _slots[s];
|
||||
if (slot.videoId >= 0) {
|
||||
// 确保旧视频彻底静音 + 停止解码(libmpv stop 不会立即断音 + 清缓存)
|
||||
try { await slot.player.stop(); } catch (_) {}
|
||||
if (slot.videoId < 0) continue;
|
||||
if (activeSet.contains(s)) {
|
||||
try { slot.player.pause(); } catch (_) {}
|
||||
} else {
|
||||
unawaited(slot.player.stop());
|
||||
slot.videoId = -1;
|
||||
slot.completeNotified = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 窗口内槽位按需加载(open 完才 play)
|
||||
// 3. 窗口内槽位按需加载(open 完才 play)
|
||||
for (var offset = -1; offset <= 1; offset++) {
|
||||
final i = index + offset;
|
||||
if (i < 0 || i >= items.length) continue;
|
||||
@@ -98,17 +106,6 @@ class FeedPlayerPool {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 窗口内非当前:pause 预缓冲(但确保不出声)
|
||||
for (var offset = -1; offset <= 1; offset++) {
|
||||
final i = index + offset;
|
||||
if (i < 0 || i >= items.length) continue;
|
||||
final slot = _slots[slotOf(i)];
|
||||
if (i == index) continue; // 当前页留到最后统一 play
|
||||
try {
|
||||
slot.player.pause();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// 4. 当前槽:播放
|
||||
currentSlot.player.play();
|
||||
}
|
||||
@@ -150,6 +147,14 @@ class FeedPlayerPool {
|
||||
void playCurrent() => currentSlot.player.play();
|
||||
void toggleCurrent() => currentSlot.player.playOrPause();
|
||||
|
||||
/// 翻页瞬间静音:暂停除目标槽位外的所有槽位,防止多个视频同时出声
|
||||
void pauseExcept({required int slotIndex}) {
|
||||
for (var i = 0; i < slotCount; i++) {
|
||||
if (i == slotIndex) continue;
|
||||
try { _slots[i].player.pause(); } catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
/// 释放全部资源(Feed 页 dispose 时调用)
|
||||
Future<void> dispose() async {
|
||||
for (final sub in _subs) {
|
||||
|
||||
Reference in New Issue
Block a user