feat: add Xtream API data models, IPTV player screen, and server entry point

This commit is contained in:
Michael committed 2025-12-06 17:39:05 +01:00
1 parent cfadc1d3bb
commit 89fd3ab56d
3 files changed
+98 -300

No files matched your search

+4 -6
View File
@@ -263,15 +263,13 @@ class ShortEPG {
final now = DateTime.now();
// Helper to decode Base64 encoded title
// Helper to decode Base64 encoded title with proper UTF-8 support
String decodeTitle(String? encodedTitle) {
if (encodedTitle == null || encodedTitle.isEmpty) return '';
try {
// Try Base64 decode
final decoded = String.fromCharCodes(
base64Decode(encodedTitle),
);
return decoded;
// Try Base64 decode with UTF-8 encoding
final bytes = base64Decode(encodedTitle);
return utf8.decode(bytes, allowMalformed: true);
} catch (_) {
// Not Base64, return as-is
return encodedTitle;
+8 -18
View File
@@ -136,29 +136,19 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
};
final modeParam = settings.modeString; // direct, transcode, or auto
final streamEndpoint = '$baseUrl/api/stream/${widget.streamId}?url=$encodedUrl&quality=$qualityParam&buffer=$bufferParam&timeout=$timeoutParam&mode=$modeParam';
// Construct the stream URL directly using fMP4 format
// We add &ext=.mp4 to force the web player to use Direct Play instead of HLS/MPEGTS
final streamEndpoint = '$baseUrl/api/stream/${widget.streamId}?url=$encodedUrl&quality=$qualityParam&buffer=$bufferParam&timeout=$timeoutParam&mode=$modeParam&ext=.mp4';
debugPrint('PlayerScreen: Starting FFmpeg stream: $streamEndpoint');
debugPrint('PlayerScreen: Starting Direct Stream: $streamEndpoint');
// Call the FFmpeg streaming endpoint
final response = await http.get(Uri.parse(streamEndpoint));
if (response.statusCode != 200) {
throw Exception('Failed to start stream: ${response.body}');
}
final data = jsonDecode(response.body);
if (data['status'] != 'started') {
throw Exception('Stream failed to start: ${data['error'] ?? 'Unknown error'}');
}
// Get the local HLS URL
hlsUrl = '$baseUrl${data['hlsUrl']}';
debugPrint('PlayerScreen: FFmpeg HLS URL: $hlsUrl');
// Use the stream endpoint directly as the video source
// The server now pipelines fMP4 directly to this URL
hlsUrl = streamEndpoint;
} else {
// For VOD and Series - use direct proxy streaming with Range support
// This allows seeking via HTTP Range requests
// This allows seeking via Range requests
final streamUrl = widget.streamType == StreamType.vod
? xtreamService.getVodStreamUrl(widget.streamId, widget.containerExtension)
: xtreamService.getSeriesStreamUrl(widget.streamId, widget.containerExtension);