Add live room preview thumbnails
This commit is contained in:
@@ -12,10 +12,12 @@ class SettingsProvider with ChangeNotifier {
|
||||
String _baseUrl = _defaultUrl;
|
||||
Color _themeColor = Colors.blue;
|
||||
ThemeMode _themeMode = ThemeMode.system;
|
||||
bool _livePreviewThumbnailsEnabled = false;
|
||||
|
||||
String get baseUrl => _baseUrl;
|
||||
Color get themeColor => _themeColor;
|
||||
ThemeMode get themeMode => _themeMode;
|
||||
bool get livePreviewThumbnailsEnabled => _livePreviewThumbnailsEnabled;
|
||||
|
||||
SettingsProvider() {
|
||||
_loadSettings();
|
||||
@@ -32,6 +34,8 @@ class SettingsProvider with ChangeNotifier {
|
||||
if (savedThemeMode != null) {
|
||||
_themeMode = _themeModeFromString(savedThemeMode);
|
||||
}
|
||||
_livePreviewThumbnailsEnabled =
|
||||
prefs.getBool('livePreviewThumbnailsEnabled') ?? false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -56,6 +60,13 @@ class SettingsProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setLivePreviewThumbnailsEnabled(bool enabled) async {
|
||||
_livePreviewThumbnailsEnabled = enabled;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('livePreviewThumbnailsEnabled', enabled);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Also provide the RTMP URL based on the same hostname
|
||||
String get rtmpUrl {
|
||||
final uri = Uri.parse(_baseUrl);
|
||||
@@ -84,6 +95,16 @@ class SettingsProvider with ChangeNotifier {
|
||||
return "$rtmpUrl/$roomId/$normalizedQuality";
|
||||
}
|
||||
|
||||
String thumbnailUrl(String roomId, {String? cacheBuster}) {
|
||||
final uri = Uri.parse(_baseUrl);
|
||||
return uri
|
||||
.replace(
|
||||
path: '/api/rooms/$roomId/thumbnail',
|
||||
queryParameters: cacheBuster == null ? null : {'t': cacheBuster},
|
||||
)
|
||||
.toString();
|
||||
}
|
||||
|
||||
ThemeMode _themeModeFromString(String value) {
|
||||
switch (value) {
|
||||
case 'light':
|
||||
|
||||
Reference in New Issue
Block a user