- Linux app id dev.foxyz.starsync, binary starsync; Windows starsync.exe, company foxyz; server starsync-server; Dart package starsync; archives starsync-<ver>-*. - 1.2.x compatibility: watch_together and watch-together-server launchers (Linux) / copies (Windows) in the archive; the updater accepts both names and relaunches the new binary; update.sh/.bat use whichever server exists. - First start copies (never moves) the old support folder and this app's Hive boxes out of ~/Documents into <support>/hive; a marker makes it run once; AppDirs is a port; settings schema version with ordered migrations. - Launcher entry dev.foxyz.starsync.desktop; the old one removed. - Repository name and URLs unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.6 KiB
Dart
77 lines
2.6 KiB
Dart
// restructure: rewrite in step 6 (Media pipeline + player host): the
|
|
// fresh player per video.
|
|
import 'dart:async';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:media_kit/media_kit.dart';
|
|
import 'package:sync_relay_core/core.dart';
|
|
import 'package:sync_relay_server/server.dart';
|
|
import 'package:starsync/src/session/session_coordinator.dart';
|
|
import 'package:starsync/src/sync/state_diff.dart';
|
|
|
|
const _mediaPath = '/home/foxyz/Videos/chiyo.mp4';
|
|
|
|
Future<void> _poll(
|
|
FutureOr<bool> Function() cond,
|
|
String what, {
|
|
Duration timeout = const Duration(seconds: 30),
|
|
}) async {
|
|
final deadline = DateTime.now().add(timeout);
|
|
while (DateTime.now().isBefore(deadline)) {
|
|
if (await cond()) return;
|
|
await Future.delayed(const Duration(milliseconds: 200));
|
|
}
|
|
fail('timed out waiting for $what');
|
|
}
|
|
|
|
void main() {
|
|
test(
|
|
'reload video: new player, same media, resynced, ready untouched; '
|
|
'leave disposes the player',
|
|
timeout: const Timeout(Duration(minutes: 2)),
|
|
() async {
|
|
MediaKit.ensureInitialized();
|
|
final server = SyncServer(const AppConfig(
|
|
port: 0, secret: 'reload', name: 'reload', mediaPath: _mediaPath));
|
|
await server.start();
|
|
final c = SessionCoordinator();
|
|
try {
|
|
await c.connect(ConnectParams(
|
|
host: '127.0.0.1',
|
|
port: server.boundPort,
|
|
secret: 'reload',
|
|
name: 'solo'));
|
|
await c.playback.player.setVolume(0);
|
|
await _poll(() => c.serverState.peek() != null, 'server state');
|
|
c.toggleReady();
|
|
await _poll(
|
|
() => c.playback.player.state.playing && c.playback.positionSecs > 2,
|
|
'solo playback past 2 s');
|
|
|
|
final old = c.playback.player;
|
|
final gen = c.playback.generation.peek();
|
|
await c.reloadVideo();
|
|
expect(identical(c.playback.player, old), isFalse);
|
|
expect(c.playback.generation.peek(), gen + 1);
|
|
expect(c.selfMember.peek()?.ready, isTrue);
|
|
|
|
await _poll(() {
|
|
final r = c.serverState.peek();
|
|
if (r == null || !c.playback.player.state.playing) return false;
|
|
final want = serverPositionAt(r, DateTime.now().toUtc());
|
|
return (c.playback.positionSecs - want).abs() < 1.5 &&
|
|
c.playback.positionSecs > 2;
|
|
}, 'reloaded player playing at the synced position');
|
|
expect(c.selfMember.peek()?.ready, isTrue);
|
|
expect(c.serverState.peek()?.transport, 'playing');
|
|
|
|
await c.leave();
|
|
expect(c.playback.alive.peek(), isFalse);
|
|
} finally {
|
|
await c.dispose();
|
|
await server.stop();
|
|
}
|
|
},
|
|
);
|
|
}
|