medialocation_controller.dart 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:get/get.dart';
  2. /// 流媒体服务数据模型
  3. class StreamingService {
  4. final String name;
  5. final String description;
  6. final String logoUrl;
  7. StreamingService({
  8. required this.name,
  9. required this.description,
  10. required this.logoUrl,
  11. });
  12. }
  13. class MedialocationController extends GetxController {
  14. // VPN连接状态
  15. final isConnected = false.obs;
  16. final isConnecting = false.obs;
  17. // 流媒体服务列表
  18. final List<StreamingService> streamingServices = [
  19. StreamingService(
  20. name: 'Netflix',
  21. description: 'Nifty Streaming',
  22. logoUrl: 'assets/images/netflix_logo.png',
  23. ),
  24. StreamingService(
  25. name: 'YouTube',
  26. description: 'YouTube Streaming',
  27. logoUrl: 'assets/images/youtube_logo.png',
  28. ),
  29. StreamingService(
  30. name: 'hulu',
  31. description: 'hulu Streaming',
  32. logoUrl: 'assets/images/hulu_logo.png',
  33. ),
  34. StreamingService(
  35. name: 'Amazon',
  36. description: 'Amazon Streaming',
  37. logoUrl: 'assets/images/amazon_logo.png',
  38. ),
  39. ];
  40. @override
  41. void onInit() {
  42. super.onInit();
  43. }
  44. @override
  45. void onReady() {
  46. super.onReady();
  47. }
  48. @override
  49. void onClose() {
  50. super.onClose();
  51. }
  52. /// 打开流媒体服务
  53. void openStreamingService(StreamingService service) {
  54. Get.snackbar(
  55. 'Opening',
  56. '${service.name} will open soon',
  57. );
  58. }
  59. /// 连接VPN
  60. void connect() {
  61. if (isConnecting.value) return;
  62. isConnecting.value = true;
  63. // 模拟连接过程
  64. Future.delayed(const Duration(seconds: 2), () {
  65. isConnecting.value = false;
  66. isConnected.value = true;
  67. Get.snackbar(
  68. 'Success',
  69. 'Connected successfully',
  70. );
  71. });
  72. }
  73. /// 断开VPN
  74. void disconnect() {
  75. isConnected.value = false;
  76. isConnecting.value = false;
  77. }
  78. }