mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-11 17:29:26 +02:00
Merge pull request #42 from R0m1k3/antigravity
feat: Implement Xtream API data models and live TV tab for IPTV funct…
This commit is contained in:
commit
b9980a9a8d
10 files changed
+641
-57
No files matched your search
+35
-9
@@ -410,7 +410,33 @@ Handler _createStreamHandler() {
|
|||||||
return Response.badRequest(body: 'Missing url parameter');
|
return Response.badRequest(body: 'Missing url parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
print('Starting FFmpeg stream for ID: $streamId');
|
// Get streaming settings from query parameters
|
||||||
|
final quality = request.url.queryParameters['quality'] ?? 'medium';
|
||||||
|
final buffer = request.url.queryParameters['buffer'] ?? 'medium';
|
||||||
|
final timeout = request.url.queryParameters['timeout'] ?? 'medium';
|
||||||
|
|
||||||
|
// Map quality to bitrate/CRF
|
||||||
|
final (int bitrate, int crf) = switch (quality) {
|
||||||
|
'low' => (1500, 26),
|
||||||
|
'high' => (5000, 20),
|
||||||
|
_ => (3000, 23), // medium
|
||||||
|
};
|
||||||
|
|
||||||
|
// Map buffer to segment duration and buffer size
|
||||||
|
final (int segmentDuration, int bufferSize) = switch (buffer) {
|
||||||
|
'low' => (2, 4000),
|
||||||
|
'high' => (6, 12000),
|
||||||
|
_ => (4, 8000), // medium
|
||||||
|
};
|
||||||
|
|
||||||
|
// Map timeout to seconds
|
||||||
|
final int timeoutSeconds = switch (timeout) {
|
||||||
|
'short' => 15,
|
||||||
|
'long' => 60,
|
||||||
|
_ => 30, // medium
|
||||||
|
};
|
||||||
|
|
||||||
|
print('Starting FFmpeg stream for ID: $streamId (quality=$quality, buffer=$buffer)');
|
||||||
print('IPTV URL: $iptvUrl');
|
print('IPTV URL: $iptvUrl');
|
||||||
|
|
||||||
// Create output directory for this stream
|
// Create output directory for this stream
|
||||||
@@ -470,21 +496,21 @@ Handler _createStreamHandler() {
|
|||||||
'-profile:v', 'main', // Main profile for better quality HD
|
'-profile:v', 'main', // Main profile for better quality HD
|
||||||
'-level', '4.0', // Higher level for HD content
|
'-level', '4.0', // Higher level for HD content
|
||||||
'-pix_fmt', 'yuv420p', // Required for browser compatibility
|
'-pix_fmt', 'yuv420p', // Required for browser compatibility
|
||||||
'-crf', '21', // Quality-based encoding (lower = better, 21 is high quality)
|
'-crf', '$crf', // Quality-based encoding from settings
|
||||||
'-b:v', '4000k', // 4 Mbps video bitrate for HD quality
|
'-b:v', '${bitrate}k', // Video bitrate from settings
|
||||||
'-maxrate', '5000k', // Allow bursts up to 5 Mbps
|
'-maxrate', '${(bitrate * 1.25).round()}k', // Allow bursts
|
||||||
'-bufsize', '8000k', // Larger buffer for smoother playback
|
'-bufsize', '${bufferSize}k', // Buffer size from settings
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Add latency flags only for live streams
|
// Add latency flags only for live streams
|
||||||
if (!isVod) {
|
if (!isVod) {
|
||||||
ffmpegArgs.addAll([
|
ffmpegArgs.addAll([
|
||||||
'-tune', 'zerolatency', // Low latency for live streaming
|
'-tune', 'zerolatency', // Low latency for live streaming
|
||||||
'-vsync', 'passthrough', // Pass through timestamps as-is
|
'-fps_mode', 'passthrough', // Pass through timestamps as-is (replaces deprecated -vsync)
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
ffmpegArgs.addAll([
|
ffmpegArgs.addAll([
|
||||||
'-vsync', 'cfr', // Constant frame rate for VOD
|
'-fps_mode', 'cfr', // Constant frame rate for VOD (replaces deprecated -vsync)
|
||||||
'-g', '48', // Keyframe every 2 seconds at 24fps
|
'-g', '48', // Keyframe every 2 seconds at 24fps
|
||||||
'-keyint_min', '48',
|
'-keyint_min', '48',
|
||||||
]);
|
]);
|
||||||
@@ -499,8 +525,8 @@ Handler _createStreamHandler() {
|
|||||||
'-ac', '2', // Force stereo
|
'-ac', '2', // Force stereo
|
||||||
// HLS output settings - optimized for stability
|
// HLS output settings - optimized for stability
|
||||||
'-f', 'hls',
|
'-f', 'hls',
|
||||||
'-hls_time', isVod ? '4' : '3', // 4s for VOD, 3s for live (better buffering)
|
'-hls_time', isVod ? '4' : '$segmentDuration', // Segment duration from settings for live
|
||||||
'-hls_list_size', isVod ? '0' : '10', // Keep all segments for VOD, 10 for live (30s buffer)
|
'-hls_list_size', isVod ? '0' : '10', // Keep all segments for VOD, 10 for live
|
||||||
'-hls_flags', isVod ? 'independent_segments' : 'delete_segments+append_list+omit_endlist+program_date_time',
|
'-hls_flags', isVod ? 'independent_segments' : 'delete_segments+append_list+omit_endlist+program_date_time',
|
||||||
'-hls_start_number_source', 'datetime', // Better segment continuity
|
'-hls_start_number_source', 'datetime', // Better segment continuity
|
||||||
'-hls_segment_filename', '${outputDir.path}/segment_%d.ts',
|
'-hls_segment_filename', '${outputDir.path}/segment_%d.ts',
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
/// Xtream API Data Models (lightweight for memory optimization)
|
/// Xtream API Data Models (lightweight for memory optimization)
|
||||||
|
|
||||||
class LiveChannel {
|
class LiveChannel {
|
||||||
@@ -261,21 +263,62 @@ class ShortEPG {
|
|||||||
|
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
|
|
||||||
|
// Helper to decode Base64 encoded title
|
||||||
|
String decodeTitle(String? encodedTitle) {
|
||||||
|
if (encodedTitle == null || encodedTitle.isEmpty) return '';
|
||||||
|
try {
|
||||||
|
// Try Base64 decode
|
||||||
|
final decoded = String.fromCharCodes(
|
||||||
|
base64Decode(encodedTitle),
|
||||||
|
);
|
||||||
|
return decoded;
|
||||||
|
} catch (_) {
|
||||||
|
// Not Base64, return as-is
|
||||||
|
return encodedTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to parse timestamp (Unix epoch or ISO format)
|
||||||
|
DateTime? parseTimestamp(dynamic value) {
|
||||||
|
if (value == null) return null;
|
||||||
|
|
||||||
|
final strValue = value.toString();
|
||||||
|
|
||||||
|
// Try parsing as Unix timestamp (seconds)
|
||||||
|
final intValue = int.tryParse(strValue);
|
||||||
|
if (intValue != null) {
|
||||||
|
return DateTime.fromMillisecondsSinceEpoch(intValue * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try parsing as ISO date string
|
||||||
|
return DateTime.tryParse(strValue);
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < epgListings.length; i++) {
|
for (var i = 0; i < epgListings.length; i++) {
|
||||||
final listing = epgListings[i];
|
final listing = epgListings[i] as Map<String, dynamic>;
|
||||||
final start = DateTime.tryParse(listing['start']?.toString() ?? '');
|
|
||||||
final stop = DateTime.tryParse(listing['stop']?.toString() ?? '');
|
// Parse start/stop timestamps (can be 'start', 'start_timestamp', or Unix epoch)
|
||||||
|
final start = parseTimestamp(listing['start']) ??
|
||||||
|
parseTimestamp(listing['start_timestamp']);
|
||||||
|
final stop = parseTimestamp(listing['stop']) ??
|
||||||
|
parseTimestamp(listing['end']) ??
|
||||||
|
parseTimestamp(listing['stop_timestamp']);
|
||||||
|
|
||||||
if (start != null && stop != null) {
|
if (start != null && stop != null) {
|
||||||
if (now.isAfter(start) && now.isBefore(stop)) {
|
if (now.isAfter(start) && now.isBefore(stop)) {
|
||||||
nowTitle = listing['title']?.toString();
|
// Decode title (may be Base64 encoded)
|
||||||
|
nowTitle = decodeTitle(listing['title']?.toString());
|
||||||
|
|
||||||
final duration = stop.difference(start).inSeconds;
|
final duration = stop.difference(start).inSeconds;
|
||||||
final elapsed = now.difference(start).inSeconds;
|
final elapsed = now.difference(start).inSeconds;
|
||||||
currentProgress = elapsed / duration;
|
if (duration > 0) {
|
||||||
|
currentProgress = elapsed / duration;
|
||||||
|
}
|
||||||
|
|
||||||
// Get next item
|
// Get next item
|
||||||
if (i + 1 < epgListings.length) {
|
if (i + 1 < epgListings.length) {
|
||||||
nextTitle = epgListings[i + 1]['title']?.toString();
|
final nextListing = epgListings[i + 1] as Map<String, dynamic>;
|
||||||
|
nextTitle = decodeTitle(nextListing['title']?.toString());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,173 @@
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
/// Streaming quality presets for Live TV
|
||||||
|
enum StreamQuality {
|
||||||
|
low, // 1.5 Mbps, CRF 26
|
||||||
|
medium, // 3 Mbps, CRF 23
|
||||||
|
high, // 5 Mbps, CRF 20
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Buffer size presets for Live TV
|
||||||
|
enum BufferSize {
|
||||||
|
low, // 2s segments, 4MB buffer
|
||||||
|
medium, // 4s segments, 8MB buffer
|
||||||
|
high, // 6s segments, 12MB buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Connection timeout presets
|
||||||
|
enum ConnectionTimeout {
|
||||||
|
short, // 15 seconds
|
||||||
|
medium, // 30 seconds
|
||||||
|
long, // 60 seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
/// EPG cache duration presets
|
||||||
|
enum EpgCacheDuration {
|
||||||
|
short, // 5 minutes
|
||||||
|
medium, // 15 minutes
|
||||||
|
long, // 60 minutes
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Transcoding mode for Live TV
|
||||||
|
enum TranscodingMode {
|
||||||
|
auto, // Auto-detect best mode
|
||||||
|
forced, // Always transcode
|
||||||
|
disabled, // Direct stream (no transcoding)
|
||||||
|
}
|
||||||
|
|
||||||
/// Keys for SharedPreferences storage
|
/// Keys for SharedPreferences storage
|
||||||
class _SettingsKeys {
|
class _SettingsKeys {
|
||||||
|
// Filters
|
||||||
static const String liveTvFilter = 'filter_live_tv';
|
static const String liveTvFilter = 'filter_live_tv';
|
||||||
static const String moviesFilter = 'filter_movies';
|
static const String moviesFilter = 'filter_movies';
|
||||||
static const String seriesFilter = 'filter_series';
|
static const String seriesFilter = 'filter_series';
|
||||||
|
|
||||||
|
// Streaming settings
|
||||||
|
static const String streamQuality = 'stream_quality';
|
||||||
|
static const String bufferSize = 'buffer_size';
|
||||||
|
static const String connectionTimeout = 'connection_timeout';
|
||||||
|
static const String autoReconnect = 'auto_reconnect';
|
||||||
|
static const String epgCacheDuration = 'epg_cache_duration';
|
||||||
|
static const String transcodingMode = 'transcoding_mode';
|
||||||
|
static const String preferDirectPlay = 'prefer_direct_play';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Settings state for IPTV preferences with persistence
|
/// Settings state for IPTV preferences with persistence
|
||||||
class IptvSettings {
|
class IptvSettings {
|
||||||
/// Category filter keywords for Live TV (comma-separated)
|
// Category filters
|
||||||
final String liveTvCategoryFilter;
|
final String liveTvCategoryFilter;
|
||||||
|
|
||||||
/// Category filter keywords for Movies (comma-separated)
|
|
||||||
final String moviesCategoryFilter;
|
final String moviesCategoryFilter;
|
||||||
|
|
||||||
/// Category filter keywords for Series (comma-separated)
|
|
||||||
final String seriesCategoryFilter;
|
final String seriesCategoryFilter;
|
||||||
|
|
||||||
|
// Streaming settings (Live TV only)
|
||||||
|
final StreamQuality streamQuality;
|
||||||
|
final BufferSize bufferSize;
|
||||||
|
final ConnectionTimeout connectionTimeout;
|
||||||
|
final bool autoReconnect;
|
||||||
|
final EpgCacheDuration epgCacheDuration;
|
||||||
|
final TranscodingMode transcodingMode;
|
||||||
|
final bool preferDirectPlay;
|
||||||
|
|
||||||
const IptvSettings({
|
const IptvSettings({
|
||||||
|
// Filters
|
||||||
this.liveTvCategoryFilter = '',
|
this.liveTvCategoryFilter = '',
|
||||||
this.moviesCategoryFilter = '',
|
this.moviesCategoryFilter = '',
|
||||||
this.seriesCategoryFilter = '',
|
this.seriesCategoryFilter = '',
|
||||||
|
// Streaming defaults
|
||||||
|
this.streamQuality = StreamQuality.medium,
|
||||||
|
this.bufferSize = BufferSize.medium,
|
||||||
|
this.connectionTimeout = ConnectionTimeout.medium,
|
||||||
|
this.autoReconnect = true,
|
||||||
|
this.epgCacheDuration = EpgCacheDuration.medium,
|
||||||
|
this.transcodingMode = TranscodingMode.auto,
|
||||||
|
this.preferDirectPlay = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
IptvSettings copyWith({
|
IptvSettings copyWith({
|
||||||
String? liveTvCategoryFilter,
|
String? liveTvCategoryFilter,
|
||||||
String? moviesCategoryFilter,
|
String? moviesCategoryFilter,
|
||||||
String? seriesCategoryFilter,
|
String? seriesCategoryFilter,
|
||||||
|
StreamQuality? streamQuality,
|
||||||
|
BufferSize? bufferSize,
|
||||||
|
ConnectionTimeout? connectionTimeout,
|
||||||
|
bool? autoReconnect,
|
||||||
|
EpgCacheDuration? epgCacheDuration,
|
||||||
|
TranscodingMode? transcodingMode,
|
||||||
|
bool? preferDirectPlay,
|
||||||
}) {
|
}) {
|
||||||
return IptvSettings(
|
return IptvSettings(
|
||||||
liveTvCategoryFilter: liveTvCategoryFilter ?? this.liveTvCategoryFilter,
|
liveTvCategoryFilter: liveTvCategoryFilter ?? this.liveTvCategoryFilter,
|
||||||
moviesCategoryFilter: moviesCategoryFilter ?? this.moviesCategoryFilter,
|
moviesCategoryFilter: moviesCategoryFilter ?? this.moviesCategoryFilter,
|
||||||
seriesCategoryFilter: seriesCategoryFilter ?? this.seriesCategoryFilter,
|
seriesCategoryFilter: seriesCategoryFilter ?? this.seriesCategoryFilter,
|
||||||
|
streamQuality: streamQuality ?? this.streamQuality,
|
||||||
|
bufferSize: bufferSize ?? this.bufferSize,
|
||||||
|
connectionTimeout: connectionTimeout ?? this.connectionTimeout,
|
||||||
|
autoReconnect: autoReconnect ?? this.autoReconnect,
|
||||||
|
epgCacheDuration: epgCacheDuration ?? this.epgCacheDuration,
|
||||||
|
transcodingMode: transcodingMode ?? this.transcodingMode,
|
||||||
|
preferDirectPlay: preferDirectPlay ?? this.preferDirectPlay,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get list of filter keywords for a given filter string
|
// ===== Streaming Value Getters =====
|
||||||
|
|
||||||
|
/// Get bitrate in kbps based on quality setting
|
||||||
|
int get bitrateKbps {
|
||||||
|
switch (streamQuality) {
|
||||||
|
case StreamQuality.low: return 1500;
|
||||||
|
case StreamQuality.medium: return 3000;
|
||||||
|
case StreamQuality.high: return 5000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get CRF value based on quality setting
|
||||||
|
int get crfValue {
|
||||||
|
switch (streamQuality) {
|
||||||
|
case StreamQuality.low: return 26;
|
||||||
|
case StreamQuality.medium: return 23;
|
||||||
|
case StreamQuality.high: return 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get HLS segment duration in seconds
|
||||||
|
int get hlsSegmentDuration {
|
||||||
|
switch (bufferSize) {
|
||||||
|
case BufferSize.low: return 2;
|
||||||
|
case BufferSize.medium: return 4;
|
||||||
|
case BufferSize.high: return 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get buffer size in KB
|
||||||
|
int get bufferSizeKb {
|
||||||
|
switch (bufferSize) {
|
||||||
|
case BufferSize.low: return 4000;
|
||||||
|
case BufferSize.medium: return 8000;
|
||||||
|
case BufferSize.high: return 12000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get connection timeout in seconds
|
||||||
|
int get timeoutSeconds {
|
||||||
|
switch (connectionTimeout) {
|
||||||
|
case ConnectionTimeout.short: return 15;
|
||||||
|
case ConnectionTimeout.medium: return 30;
|
||||||
|
case ConnectionTimeout.long: return 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get EPG cache duration in minutes
|
||||||
|
int get epgCacheMinutes {
|
||||||
|
switch (epgCacheDuration) {
|
||||||
|
case EpgCacheDuration.short: return 5;
|
||||||
|
case EpgCacheDuration.medium: return 15;
|
||||||
|
case EpgCacheDuration.long: return 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== Filter Methods =====
|
||||||
|
|
||||||
static List<String> _parseKeywords(String filter) {
|
static List<String> _parseKeywords(String filter) {
|
||||||
if (filter.isEmpty) return [];
|
if (filter.isEmpty) return [];
|
||||||
return filter
|
return filter
|
||||||
@@ -47,38 +177,28 @@ class IptvSettings {
|
|||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get live TV filter keywords
|
|
||||||
List<String> get liveTvKeywords => _parseKeywords(liveTvCategoryFilter);
|
List<String> get liveTvKeywords => _parseKeywords(liveTvCategoryFilter);
|
||||||
|
|
||||||
/// Get movies filter keywords
|
|
||||||
List<String> get moviesKeywords => _parseKeywords(moviesCategoryFilter);
|
List<String> get moviesKeywords => _parseKeywords(moviesCategoryFilter);
|
||||||
|
|
||||||
/// Get series filter keywords
|
|
||||||
List<String> get seriesKeywords => _parseKeywords(seriesCategoryFilter);
|
List<String> get seriesKeywords => _parseKeywords(seriesCategoryFilter);
|
||||||
|
|
||||||
/// Check if a category name matches the Live TV filter
|
|
||||||
bool matchesLiveTvFilter(String categoryName) {
|
bool matchesLiveTvFilter(String categoryName) {
|
||||||
return _matchesFilter(categoryName, liveTvKeywords);
|
return _matchesFilter(categoryName, liveTvKeywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a category name matches the Movies filter
|
|
||||||
bool matchesMoviesFilter(String categoryName) {
|
bool matchesMoviesFilter(String categoryName) {
|
||||||
return _matchesFilter(categoryName, moviesKeywords);
|
return _matchesFilter(categoryName, moviesKeywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a category name matches the Series filter
|
|
||||||
bool matchesSeriesFilter(String categoryName) {
|
bool matchesSeriesFilter(String categoryName) {
|
||||||
return _matchesFilter(categoryName, seriesKeywords);
|
return _matchesFilter(categoryName, seriesKeywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generic filter matching
|
|
||||||
bool _matchesFilter(String categoryName, List<String> keywords) {
|
bool _matchesFilter(String categoryName, List<String> keywords) {
|
||||||
if (keywords.isEmpty) return true;
|
if (keywords.isEmpty) return true;
|
||||||
final upperName = categoryName.toUpperCase();
|
final upperName = categoryName.toUpperCase();
|
||||||
return keywords.any((keyword) => upperName.contains(keyword));
|
return keywords.any((keyword) => upperName.contains(keyword));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Legacy method for backwards compatibility
|
|
||||||
bool matchesFilter(String categoryName) => matchesLiveTvFilter(categoryName);
|
bool matchesFilter(String categoryName) => matchesLiveTvFilter(categoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,24 +218,52 @@ class IptvSettingsNotifier extends StateNotifier<IptvSettings> {
|
|||||||
try {
|
try {
|
||||||
_prefs = await SharedPreferences.getInstance();
|
_prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
// Load filters
|
||||||
final liveTv = _prefs?.getString(_SettingsKeys.liveTvFilter) ?? '';
|
final liveTv = _prefs?.getString(_SettingsKeys.liveTvFilter) ?? '';
|
||||||
final movies = _prefs?.getString(_SettingsKeys.moviesFilter) ?? '';
|
final movies = _prefs?.getString(_SettingsKeys.moviesFilter) ?? '';
|
||||||
final series = _prefs?.getString(_SettingsKeys.seriesFilter) ?? '';
|
final series = _prefs?.getString(_SettingsKeys.seriesFilter) ?? '';
|
||||||
|
|
||||||
|
// Load streaming settings
|
||||||
|
final quality = StreamQuality.values[
|
||||||
|
_prefs?.getInt(_SettingsKeys.streamQuality) ?? StreamQuality.medium.index
|
||||||
|
];
|
||||||
|
final buffer = BufferSize.values[
|
||||||
|
_prefs?.getInt(_SettingsKeys.bufferSize) ?? BufferSize.medium.index
|
||||||
|
];
|
||||||
|
final timeout = ConnectionTimeout.values[
|
||||||
|
_prefs?.getInt(_SettingsKeys.connectionTimeout) ?? ConnectionTimeout.medium.index
|
||||||
|
];
|
||||||
|
final reconnect = _prefs?.getBool(_SettingsKeys.autoReconnect) ?? true;
|
||||||
|
final epgCache = EpgCacheDuration.values[
|
||||||
|
_prefs?.getInt(_SettingsKeys.epgCacheDuration) ?? EpgCacheDuration.medium.index
|
||||||
|
];
|
||||||
|
final transcoding = TranscodingMode.values[
|
||||||
|
_prefs?.getInt(_SettingsKeys.transcodingMode) ?? TranscodingMode.auto.index
|
||||||
|
];
|
||||||
|
final directPlay = _prefs?.getBool(_SettingsKeys.preferDirectPlay) ?? false;
|
||||||
|
|
||||||
state = IptvSettings(
|
state = IptvSettings(
|
||||||
liveTvCategoryFilter: liveTv,
|
liveTvCategoryFilter: liveTv,
|
||||||
moviesCategoryFilter: movies,
|
moviesCategoryFilter: movies,
|
||||||
seriesCategoryFilter: series,
|
seriesCategoryFilter: series,
|
||||||
|
streamQuality: quality,
|
||||||
|
bufferSize: buffer,
|
||||||
|
connectionTimeout: timeout,
|
||||||
|
autoReconnect: reconnect,
|
||||||
|
epgCacheDuration: epgCache,
|
||||||
|
transcodingMode: transcoding,
|
||||||
|
preferDirectPlay: directPlay,
|
||||||
);
|
);
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
print('Settings loaded: LiveTV="$liveTv", Movies="$movies", Series="$series"');
|
print('Settings loaded: LiveTV="$liveTv", Quality=${quality.name}');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error loading settings: $e');
|
print('Error loading settings: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save a setting to SharedPreferences
|
// ===== Save Helpers =====
|
||||||
|
|
||||||
Future<void> _saveString(String key, String value) async {
|
Future<void> _saveString(String key, String value) async {
|
||||||
try {
|
try {
|
||||||
_prefs ??= await SharedPreferences.getInstance();
|
_prefs ??= await SharedPreferences.getInstance();
|
||||||
@@ -125,41 +273,89 @@ class IptvSettingsNotifier extends StateNotifier<IptvSettings> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set Live TV category filter
|
Future<void> _saveInt(String key, int value) async {
|
||||||
|
try {
|
||||||
|
_prefs ??= await SharedPreferences.getInstance();
|
||||||
|
await _prefs?.setInt(key, value);
|
||||||
|
} catch (e) {
|
||||||
|
print('Error saving setting $key: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveBool(String key, bool value) async {
|
||||||
|
try {
|
||||||
|
_prefs ??= await SharedPreferences.getInstance();
|
||||||
|
await _prefs?.setBool(key, value);
|
||||||
|
} catch (e) {
|
||||||
|
print('Error saving setting $key: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== Filter Setters =====
|
||||||
|
|
||||||
void setLiveTvFilter(String filter) {
|
void setLiveTvFilter(String filter) {
|
||||||
state = state.copyWith(liveTvCategoryFilter: filter);
|
state = state.copyWith(liveTvCategoryFilter: filter);
|
||||||
_saveString(_SettingsKeys.liveTvFilter, filter);
|
_saveString(_SettingsKeys.liveTvFilter, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set Movies category filter
|
|
||||||
void setMoviesFilter(String filter) {
|
void setMoviesFilter(String filter) {
|
||||||
state = state.copyWith(moviesCategoryFilter: filter);
|
state = state.copyWith(moviesCategoryFilter: filter);
|
||||||
_saveString(_SettingsKeys.moviesFilter, filter);
|
_saveString(_SettingsKeys.moviesFilter, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set Series category filter
|
|
||||||
void setSeriesFilter(String filter) {
|
void setSeriesFilter(String filter) {
|
||||||
state = state.copyWith(seriesCategoryFilter: filter);
|
state = state.copyWith(seriesCategoryFilter: filter);
|
||||||
_saveString(_SettingsKeys.seriesFilter, filter);
|
_saveString(_SettingsKeys.seriesFilter, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear Live TV filter
|
|
||||||
void clearLiveTvFilter() => setLiveTvFilter('');
|
void clearLiveTvFilter() => setLiveTvFilter('');
|
||||||
|
|
||||||
/// Clear Movies filter
|
|
||||||
void clearMoviesFilter() => setMoviesFilter('');
|
void clearMoviesFilter() => setMoviesFilter('');
|
||||||
|
|
||||||
/// Clear Series filter
|
|
||||||
void clearSeriesFilter() => setSeriesFilter('');
|
void clearSeriesFilter() => setSeriesFilter('');
|
||||||
|
|
||||||
/// Clear all filters
|
|
||||||
void clearAllFilters() {
|
void clearAllFilters() {
|
||||||
clearLiveTvFilter();
|
clearLiveTvFilter();
|
||||||
clearMoviesFilter();
|
clearMoviesFilter();
|
||||||
clearSeriesFilter();
|
clearSeriesFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy methods for backwards compatibility
|
// ===== Streaming Setters =====
|
||||||
|
|
||||||
|
void setStreamQuality(StreamQuality quality) {
|
||||||
|
state = state.copyWith(streamQuality: quality);
|
||||||
|
_saveInt(_SettingsKeys.streamQuality, quality.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBufferSize(BufferSize buffer) {
|
||||||
|
state = state.copyWith(bufferSize: buffer);
|
||||||
|
_saveInt(_SettingsKeys.bufferSize, buffer.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setConnectionTimeout(ConnectionTimeout timeout) {
|
||||||
|
state = state.copyWith(connectionTimeout: timeout);
|
||||||
|
_saveInt(_SettingsKeys.connectionTimeout, timeout.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAutoReconnect(bool value) {
|
||||||
|
state = state.copyWith(autoReconnect: value);
|
||||||
|
_saveBool(_SettingsKeys.autoReconnect, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setEpgCacheDuration(EpgCacheDuration duration) {
|
||||||
|
state = state.copyWith(epgCacheDuration: duration);
|
||||||
|
_saveInt(_SettingsKeys.epgCacheDuration, duration.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTranscodingMode(TranscodingMode mode) {
|
||||||
|
state = state.copyWith(transcodingMode: mode);
|
||||||
|
_saveInt(_SettingsKeys.transcodingMode, mode.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPreferDirectPlay(bool value) {
|
||||||
|
state = state.copyWith(preferDirectPlay: value);
|
||||||
|
_saveBool(_SettingsKeys.preferDirectPlay, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy methods
|
||||||
void setCategoryFilter(String filter) => setLiveTvFilter(filter);
|
void setCategoryFilter(String filter) => setLiveTvFilter(filter);
|
||||||
void clearCategoryFilter() => clearLiveTvFilter();
|
void clearCategoryFilter() => clearLiveTvFilter();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'dart:async';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import '../providers/xtream_provider.dart';
|
import '../providers/xtream_provider.dart';
|
||||||
import '../providers/playback_positions_provider.dart';
|
import '../providers/playback_positions_provider.dart';
|
||||||
|
import '../providers/settings_provider.dart';
|
||||||
import '../widgets/epg_overlay.dart';
|
import '../widgets/epg_overlay.dart';
|
||||||
import '../../../core/models/playlist_config.dart';
|
import '../../../core/models/playlist_config.dart';
|
||||||
|
|
||||||
@@ -111,11 +112,30 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
|||||||
_statusMessage = 'Starting stream transcoding...';
|
_statusMessage = 'Starting stream transcoding...';
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build the FFmpeg endpoint URL
|
// Build the FFmpeg endpoint URL with streaming settings
|
||||||
|
final settings = ref.read(iptvSettingsProvider);
|
||||||
final baseUrl = html.window.location.origin;
|
final baseUrl = html.window.location.origin;
|
||||||
final iptvUrl = '${widget.playlist.dns}/live/${widget.playlist.username}/${widget.playlist.password}/${widget.streamId}.ts';
|
final iptvUrl = '${widget.playlist.dns}/live/${widget.playlist.username}/${widget.playlist.password}/${widget.streamId}.ts';
|
||||||
final encodedUrl = Uri.encodeComponent(iptvUrl);
|
final encodedUrl = Uri.encodeComponent(iptvUrl);
|
||||||
final streamEndpoint = '$baseUrl/api/stream/${widget.streamId}?url=$encodedUrl';
|
|
||||||
|
// Map enum values to string params
|
||||||
|
final qualityParam = switch (settings.streamQuality) {
|
||||||
|
StreamQuality.low => 'low',
|
||||||
|
StreamQuality.medium => 'medium',
|
||||||
|
StreamQuality.high => 'high',
|
||||||
|
};
|
||||||
|
final bufferParam = switch (settings.bufferSize) {
|
||||||
|
BufferSize.low => 'low',
|
||||||
|
BufferSize.medium => 'medium',
|
||||||
|
BufferSize.high => 'high',
|
||||||
|
};
|
||||||
|
final timeoutParam = switch (settings.connectionTimeout) {
|
||||||
|
ConnectionTimeout.short => 'short',
|
||||||
|
ConnectionTimeout.medium => 'medium',
|
||||||
|
ConnectionTimeout.long => 'long',
|
||||||
|
};
|
||||||
|
|
||||||
|
final streamEndpoint = '$baseUrl/api/stream/${widget.streamId}?url=$encodedUrl&quality=$qualityParam&buffer=$bufferParam&timeout=$timeoutParam';
|
||||||
|
|
||||||
debugPrint('PlayerScreen: Starting FFmpeg stream: $streamEndpoint');
|
debugPrint('PlayerScreen: Starting FFmpeg stream: $streamEndpoint');
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ class _LiveTVTabState extends ConsumerState<LiveTVTab>
|
|||||||
|
|
||||||
// Proxy HTTP images through our server to avoid Mixed Content blocking
|
// Proxy HTTP images through our server to avoid Mixed Content blocking
|
||||||
if (hasIcon && channel.streamIcon.startsWith('http://')) {
|
if (hasIcon && channel.streamIcon.startsWith('http://')) {
|
||||||
iconUrl = '/api/xtream/${Uri.encodeComponent(channel.streamIcon)}';
|
iconUrl = '/api/xtream/${channel.streamIcon}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final Widget placeholder = Container(
|
final Widget placeholder = Container(
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import '../../auth/providers/auth_provider.dart';
|
import '../../auth/providers/auth_provider.dart';
|
||||||
import '../providers/settings_provider.dart';
|
import '../providers/settings_provider.dart';
|
||||||
|
import 'streaming_settings_tab.dart';
|
||||||
|
|
||||||
|
/// Main Settings tab with sub-tabs for Filters and Streaming
|
||||||
class SettingsTab extends ConsumerStatefulWidget {
|
class SettingsTab extends ConsumerStatefulWidget {
|
||||||
const SettingsTab({super.key});
|
const SettingsTab({super.key});
|
||||||
|
|
||||||
@@ -12,7 +14,8 @@ class SettingsTab extends ConsumerStatefulWidget {
|
|||||||
ConsumerState<SettingsTab> createState() => _SettingsTabState();
|
ConsumerState<SettingsTab> createState() => _SettingsTabState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SettingsTabState extends ConsumerState<SettingsTab> {
|
class _SettingsTabState extends ConsumerState<SettingsTab> with SingleTickerProviderStateMixin {
|
||||||
|
late TabController _tabController;
|
||||||
late TextEditingController _liveTvController;
|
late TextEditingController _liveTvController;
|
||||||
late TextEditingController _moviesController;
|
late TextEditingController _moviesController;
|
||||||
late TextEditingController _seriesController;
|
late TextEditingController _seriesController;
|
||||||
@@ -21,6 +24,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_tabController = TabController(length: 2, vsync: this);
|
||||||
_liveTvController = TextEditingController();
|
_liveTvController = TextEditingController();
|
||||||
_moviesController = TextEditingController();
|
_moviesController = TextEditingController();
|
||||||
_seriesController = TextEditingController();
|
_seriesController = TextEditingController();
|
||||||
@@ -28,6 +32,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_tabController.dispose();
|
||||||
_liveTvController.dispose();
|
_liveTvController.dispose();
|
||||||
_moviesController.dispose();
|
_moviesController.dispose();
|
||||||
_seriesController.dispose();
|
_seriesController.dispose();
|
||||||
@@ -57,6 +62,38 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
if (!_initialized) _syncControllers(settings);
|
if (!_initialized) _syncControllers(settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
// TabBar
|
||||||
|
Container(
|
||||||
|
color: Theme.of(context).colorScheme.surface,
|
||||||
|
child: TabBar(
|
||||||
|
controller: _tabController,
|
||||||
|
tabs: const [
|
||||||
|
Tab(icon: Icon(Icons.filter_list), text: 'Filtres'),
|
||||||
|
Tab(icon: Icon(Icons.stream), text: 'Streaming'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// TabBarView
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
controller: _tabController,
|
||||||
|
children: [
|
||||||
|
// Filters Tab
|
||||||
|
_buildFiltersTab(context, currentUser, settings),
|
||||||
|
|
||||||
|
// Streaming Tab
|
||||||
|
const StreamingSettingsTab(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFiltersTab(BuildContext context, dynamic currentUser, IptvSettings settings) {
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
children: [
|
children: [
|
||||||
@@ -65,7 +102,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.person),
|
leading: const Icon(Icons.person),
|
||||||
title: Text(
|
title: Text(
|
||||||
'Logged in as',
|
'Connecté en tant que',
|
||||||
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey),
|
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
@@ -84,7 +121,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
|
|
||||||
// Category filters section
|
// Category filters section
|
||||||
Text(
|
Text(
|
||||||
'Category Filters',
|
'Filtres de Catégories',
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -92,7 +129,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
'Only categories containing one of these keywords will be shown. Separate with commas.',
|
'Seules les catégories contenant un de ces mots-clés seront affichées. Séparez par des virgules.',
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: Colors.grey.shade600,
|
color: Colors.grey.shade600,
|
||||||
@@ -102,7 +139,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
|
|
||||||
// Live TV Filter
|
// Live TV Filter
|
||||||
_buildFilterCard(
|
_buildFilterCard(
|
||||||
title: 'Live TV Filter',
|
title: 'Filtre TV Live',
|
||||||
icon: Icons.live_tv,
|
icon: Icons.live_tv,
|
||||||
controller: _liveTvController,
|
controller: _liveTvController,
|
||||||
keywords: settings.liveTvKeywords,
|
keywords: settings.liveTvKeywords,
|
||||||
@@ -118,7 +155,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
|
|
||||||
// Movies Filter
|
// Movies Filter
|
||||||
_buildFilterCard(
|
_buildFilterCard(
|
||||||
title: 'Movies Filter',
|
title: 'Filtre Films',
|
||||||
icon: Icons.movie,
|
icon: Icons.movie,
|
||||||
controller: _moviesController,
|
controller: _moviesController,
|
||||||
keywords: settings.moviesKeywords,
|
keywords: settings.moviesKeywords,
|
||||||
@@ -134,7 +171,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
|
|
||||||
// Series Filter
|
// Series Filter
|
||||||
_buildFilterCard(
|
_buildFilterCard(
|
||||||
title: 'Series Filter',
|
title: 'Filtre Séries',
|
||||||
icon: Icons.tv,
|
icon: Icons.tv,
|
||||||
controller: _seriesController,
|
controller: _seriesController,
|
||||||
keywords: settings.seriesKeywords,
|
keywords: settings.seriesKeywords,
|
||||||
@@ -153,7 +190,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.admin_panel_settings),
|
leading: const Icon(Icons.admin_panel_settings),
|
||||||
title: Text('Admin Panel', style: GoogleFonts.roboto()),
|
title: Text('Panneau Admin', style: GoogleFonts.roboto()),
|
||||||
trailing: const Icon(Icons.chevron_right),
|
trailing: const Icon(Icons.chevron_right),
|
||||||
onTap: () => context.go('/admin'),
|
onTap: () => context.go('/admin'),
|
||||||
),
|
),
|
||||||
@@ -165,7 +202,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.playlist_play),
|
leading: const Icon(Icons.playlist_play),
|
||||||
title: Text('Change Playlist', style: GoogleFonts.roboto()),
|
title: Text('Changer de Playlist', style: GoogleFonts.roboto()),
|
||||||
trailing: const Icon(Icons.chevron_right),
|
trailing: const Icon(Icons.chevron_right),
|
||||||
onTap: () => context.go('/playlists'),
|
onTap: () => context.go('/playlists'),
|
||||||
),
|
),
|
||||||
@@ -176,7 +213,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.info_outline),
|
leading: const Icon(Icons.info_outline),
|
||||||
title: Text('About', style: GoogleFonts.roboto()),
|
title: Text('À propos', style: GoogleFonts.roboto()),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'XtremFlow IPTV v1.0.0',
|
'XtremFlow IPTV v1.0.0',
|
||||||
style: GoogleFonts.roboto(fontSize: 12),
|
style: GoogleFonts.roboto(fontSize: 12),
|
||||||
@@ -192,7 +229,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
|||||||
context.go('/login');
|
context.go('/login');
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.logout),
|
icon: const Icon(Icons.logout),
|
||||||
label: const Text('Logout'),
|
label: const Text('Déconnexion'),
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
backgroundColor: Colors.red.shade700,
|
backgroundColor: Colors.red.shade700,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
|||||||
@@ -0,0 +1,262 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import '../providers/settings_provider.dart';
|
||||||
|
|
||||||
|
/// Streaming settings tab for Live TV configuration
|
||||||
|
class StreamingSettingsTab extends ConsumerWidget {
|
||||||
|
const StreamingSettingsTab({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final settings = ref.watch(iptvSettingsProvider);
|
||||||
|
final notifier = ref.read(iptvSettingsProvider.notifier);
|
||||||
|
|
||||||
|
return ListView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
children: [
|
||||||
|
// Header
|
||||||
|
Text(
|
||||||
|
'Paramètres Streaming Live TV',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Ces paramètres s\'appliquent uniquement aux flux TV en direct.',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
|
// Quality Section
|
||||||
|
_buildSectionCard(
|
||||||
|
context: context,
|
||||||
|
title: 'Qualité Vidéo',
|
||||||
|
icon: Icons.high_quality,
|
||||||
|
children: [
|
||||||
|
_buildDropdownTile<StreamQuality>(
|
||||||
|
title: 'Qualité du flux',
|
||||||
|
subtitle: 'Bitrate: ${settings.bitrateKbps} kbps',
|
||||||
|
value: settings.streamQuality,
|
||||||
|
items: StreamQuality.values,
|
||||||
|
onChanged: (v) => notifier.setStreamQuality(v!),
|
||||||
|
labelBuilder: (v) => switch (v) {
|
||||||
|
StreamQuality.low => 'Faible (1.5 Mbps)',
|
||||||
|
StreamQuality.medium => 'Moyen (3 Mbps)',
|
||||||
|
StreamQuality.high => 'Élevé (5 Mbps)',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Buffer Section
|
||||||
|
_buildSectionCard(
|
||||||
|
context: context,
|
||||||
|
title: 'Buffer & Latence',
|
||||||
|
icon: Icons.speed,
|
||||||
|
children: [
|
||||||
|
_buildDropdownTile<BufferSize>(
|
||||||
|
title: 'Taille du buffer',
|
||||||
|
subtitle: 'Segments HLS: ${settings.hlsSegmentDuration}s',
|
||||||
|
value: settings.bufferSize,
|
||||||
|
items: BufferSize.values,
|
||||||
|
onChanged: (v) => notifier.setBufferSize(v!),
|
||||||
|
labelBuilder: (v) => switch (v) {
|
||||||
|
BufferSize.low => 'Faible (latence min)',
|
||||||
|
BufferSize.medium => 'Moyen (équilibré)',
|
||||||
|
BufferSize.high => 'Élevé (stabilité max)',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Connection Section
|
||||||
|
_buildSectionCard(
|
||||||
|
context: context,
|
||||||
|
title: 'Connexion',
|
||||||
|
icon: Icons.wifi,
|
||||||
|
children: [
|
||||||
|
_buildDropdownTile<ConnectionTimeout>(
|
||||||
|
title: 'Timeout de connexion',
|
||||||
|
subtitle: '${settings.timeoutSeconds} secondes',
|
||||||
|
value: settings.connectionTimeout,
|
||||||
|
items: ConnectionTimeout.values,
|
||||||
|
onChanged: (v) => notifier.setConnectionTimeout(v!),
|
||||||
|
labelBuilder: (v) => switch (v) {
|
||||||
|
ConnectionTimeout.short => 'Court (15s)',
|
||||||
|
ConnectionTimeout.medium => 'Moyen (30s)',
|
||||||
|
ConnectionTimeout.long => 'Long (60s)',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(
|
||||||
|
'Reconnexion automatique',
|
||||||
|
style: GoogleFonts.roboto(fontSize: 14),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'Se reconnecter en cas de coupure',
|
||||||
|
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey),
|
||||||
|
),
|
||||||
|
value: settings.autoReconnect,
|
||||||
|
onChanged: (v) => notifier.setAutoReconnect(v),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Transcoding Section
|
||||||
|
_buildSectionCard(
|
||||||
|
context: context,
|
||||||
|
title: 'Transcodage',
|
||||||
|
icon: Icons.transform,
|
||||||
|
children: [
|
||||||
|
_buildDropdownTile<TranscodingMode>(
|
||||||
|
title: 'Mode de transcodage',
|
||||||
|
subtitle: 'Comment le flux est traité',
|
||||||
|
value: settings.transcodingMode,
|
||||||
|
items: TranscodingMode.values,
|
||||||
|
onChanged: (v) => notifier.setTranscodingMode(v!),
|
||||||
|
labelBuilder: (v) => switch (v) {
|
||||||
|
TranscodingMode.auto => 'Auto (recommandé)',
|
||||||
|
TranscodingMode.forced => 'Forcé (toujours transcoder)',
|
||||||
|
TranscodingMode.disabled => 'Désactivé (direct)',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(
|
||||||
|
'Préférer lecture directe',
|
||||||
|
style: GoogleFonts.roboto(fontSize: 14),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'Utiliser le flux original si compatible',
|
||||||
|
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey),
|
||||||
|
),
|
||||||
|
value: settings.preferDirectPlay,
|
||||||
|
onChanged: (v) => notifier.setPreferDirectPlay(v),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Cache Section
|
||||||
|
_buildSectionCard(
|
||||||
|
context: context,
|
||||||
|
title: 'Cache EPG',
|
||||||
|
icon: Icons.schedule,
|
||||||
|
children: [
|
||||||
|
_buildDropdownTile<EpgCacheDuration>(
|
||||||
|
title: 'Durée du cache EPG',
|
||||||
|
subtitle: '${settings.epgCacheMinutes} minutes',
|
||||||
|
value: settings.epgCacheDuration,
|
||||||
|
items: EpgCacheDuration.values,
|
||||||
|
onChanged: (v) => notifier.setEpgCacheDuration(v!),
|
||||||
|
labelBuilder: (v) => switch (v) {
|
||||||
|
EpgCacheDuration.short => 'Court (5 min)',
|
||||||
|
EpgCacheDuration.medium => 'Moyen (15 min)',
|
||||||
|
EpgCacheDuration.long => 'Long (1 heure)',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
|
// Info card
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.blue.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: Colors.blue.withOpacity(0.3)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.info_outline, color: Colors.blue),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'Les changements prennent effet immédiatement pour les nouveaux flux.',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.blue.shade700,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSectionCard({
|
||||||
|
required BuildContext context,
|
||||||
|
required String title,
|
||||||
|
required IconData icon,
|
||||||
|
required List<Widget> children,
|
||||||
|
}) {
|
||||||
|
return Card(
|
||||||
|
elevation: 2,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 20, color: Theme.of(context).colorScheme.primary),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
|
...children,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDropdownTile<T>({
|
||||||
|
required String title,
|
||||||
|
required String subtitle,
|
||||||
|
required T value,
|
||||||
|
required List<T> items,
|
||||||
|
required ValueChanged<T?> onChanged,
|
||||||
|
required String Function(T) labelBuilder,
|
||||||
|
}) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(title, style: GoogleFonts.roboto(fontSize: 14)),
|
||||||
|
subtitle: Text(subtitle, style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey)),
|
||||||
|
trailing: DropdownButton<T>(
|
||||||
|
value: value,
|
||||||
|
underline: const SizedBox(),
|
||||||
|
items: items.map((item) {
|
||||||
|
return DropdownMenuItem<T>(
|
||||||
|
value: item,
|
||||||
|
child: Text(
|
||||||
|
labelBuilder(item),
|
||||||
|
style: GoogleFonts.roboto(fontSize: 13),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: onChanged,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 356 KiB After Width: | Height: | Size: 425 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 356 KiB After Width: | Height: | Size: 425 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 356 KiB After Width: | Height: | Size: 425 KiB |
Reference in new issue
Block a user