Initial commit

This commit is contained in:
admin1
2026-07-14 11:11:36 +08:00
commit 656499cf94
604 changed files with 119518 additions and 0 deletions
@@ -0,0 +1,43 @@
import '../../../core/infra/player_engine/player_engine.dart';
import 'player_engine_resolution.dart';
class PlayerEngineHolder {
PlayerEngine? _engine;
PlayerEngineKind? _kind;
PlayerEngine? get current => _engine;
Future<PlayerEngine> acquire(
PlayerEngineKind kind,
PlayerEngine Function() create,
) async {
final existing = _engine;
if (existing != null && _kind == kind) {
return existing;
}
_engine = null;
_kind = null;
if (existing != null) {
await existing.dispose();
}
final next = create();
_engine = next;
_kind = kind;
return next;
}
Future<void> dispose() async {
final engine = _engine;
_engine = null;
_kind = null;
if (engine != null) {
await engine.dispose();
}
}
}