Phase 3 completed: Flutter MVP with live streaming and auto-refresh
This commit is contained in:
33
frontend/lib/providers/settings_provider.dart
Normal file
33
frontend/lib/providers/settings_provider.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SettingsProvider with ChangeNotifier {
|
||||
// Default server address for local development.
|
||||
// Using 10.0.2.2 for Android emulator or localhost for Desktop.
|
||||
String _baseUrl = "http://localhost:8080";
|
||||
|
||||
String get baseUrl => _baseUrl;
|
||||
|
||||
SettingsProvider() {
|
||||
_loadSettings();
|
||||
}
|
||||
|
||||
void _loadSettings() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_baseUrl = prefs.getString('baseUrl') ?? _baseUrl;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setBaseUrl(String url) async {
|
||||
_baseUrl = url;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('baseUrl', url);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Also provide the RTMP URL based on the same hostname
|
||||
String get rtmpUrl {
|
||||
final uri = Uri.parse(_baseUrl);
|
||||
return "rtmp://${uri.host}:1935/live";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user