46 lines
1.7 KiB
Dart
46 lines
1.7 KiB
Dart
// lib/services/cast/cast_backend_switcher.dart
|
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:aves/widgets/cast/cast_controller.dart';
|
|
import 'package:aves/widgets/cast/google_cast_controller.dart';
|
|
|
|
class CastBackendSwitcher {
|
|
static const MethodChannel _pluginChannel =
|
|
MethodChannel('google_cast'); // plugin unico
|
|
|
|
// ------------------------------------------------------------
|
|
// ⭐ Attiva Google Cast (CAF)
|
|
// ------------------------------------------------------------
|
|
static Future<void> activateGoogleCast() async {
|
|
// 1) abilita plugin nativo Google Cast
|
|
await _pluginChannel.invokeMethod('setEnabled', true);
|
|
|
|
// 2) reset Google Cast (chiude sessioni, pulisce stato)
|
|
GoogleCastController.instance.forceReset();
|
|
|
|
// 3) seleziona backend Google
|
|
await CastController.instance.setBackend(CastBackend.google);
|
|
}
|
|
|
|
// ------------------------------------------------------------
|
|
// ⭐ Attiva FAST (usa Google Cast SDK ma NON richiede reset)
|
|
// ------------------------------------------------------------
|
|
static Future<void> activateFastCast() async {
|
|
// FAST usa il Cast SDK → NON disabilitare Google Cast
|
|
// NON chiudere sessioni
|
|
// NON resettare GoogleCastController
|
|
|
|
// seleziona backend FAST
|
|
await CastController.instance.setBackend(CastBackend.fast);
|
|
}
|
|
|
|
// ------------------------------------------------------------
|
|
// ⭐ Attiva DLNA (NON usa Google Cast SDK)
|
|
// ------------------------------------------------------------
|
|
static Future<void> activateDlnaCast() async {
|
|
// DLNA non usa il Cast SDK → NON toccare setEnabled()
|
|
|
|
// seleziona backend DLNA
|
|
await CastController.instance.setBackend(CastBackend.dlna);
|
|
}
|
|
}
|