mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-20 21:48:06 +02:00
feat: add Xtream service for IPTV integration and a lite player HTML file.
This commit is contained in:
1 parent
610c0064c1
commit
e0c3ff2be9
2 files changed
+27
-30
No files matched your search
@@ -37,10 +37,15 @@ class XtreamService {
|
|||||||
return html.window.location.protocol == 'https:';
|
return html.window.location.protocol == 'https:';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrap URL with proxy if needed (for HTTPS to HTTP bridge)
|
/// Wrap URL with proxy for all external IPTV URLs
|
||||||
|
///
|
||||||
|
/// Always use proxy for HTTP URLs to:
|
||||||
|
/// 1. Handle HTTPS->HTTP mixed content
|
||||||
|
/// 2. Provide Range header support for seeking
|
||||||
|
/// 3. Normalize headers and handle redirects
|
||||||
String _wrapWithProxy(String url) {
|
String _wrapWithProxy(String url) {
|
||||||
// If we're on HTTPS and the target URL is HTTP, use the proxy
|
// Always proxy HTTP URLs for consistent streaming behavior
|
||||||
if (_isHttps && url.startsWith('http://')) {
|
if (url.startsWith('http://')) {
|
||||||
final baseUrl = html.window.location.origin;
|
final baseUrl = html.window.location.origin;
|
||||||
return '$baseUrl/api/xtream/$url';
|
return '$baseUrl/api/xtream/$url';
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-27
@@ -361,38 +361,30 @@
|
|||||||
log('Stream type: ' + streamType);
|
log('Stream type: ' + streamType);
|
||||||
const lowerUrl = streamUrl.toLowerCase();
|
const lowerUrl = streamUrl.toLowerCase();
|
||||||
|
|
||||||
// SPECIAL: /api/stream/ endpoint handling - differentiate Live vs VOD
|
// SPECIAL: /api/stream/ endpoint handling - ALWAYS returns JSON with HLS playlist
|
||||||
if (streamUrl.includes('/api/stream/')) {
|
if (streamUrl.includes('/api/stream/')) {
|
||||||
if (streamType === 'live') {
|
// Both Live TV and VOD use /api/stream/ which returns JSON with HLS playlist URL
|
||||||
// LIVE TV: Use MPEG-TS direct streaming
|
log((streamType === 'live' ? 'Live TV' : 'VOD') + ' via /api/stream/ - fetching HLS...');
|
||||||
log('Live TV via /api/stream/ - using MPEG-TS direct');
|
showLoading(streamType === 'live' ? 'Connecting to live stream...' : 'Initializing stream...');
|
||||||
showLoading('Connecting to live stream...');
|
|
||||||
await playWithMpegTS(streamUrl, true); // isLive=true
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// VOD: Fetch JSON to get HLS playlist URL (transcoding mode)
|
|
||||||
log('VOD via /api/stream/ - fetching HLS playlist...');
|
|
||||||
showLoading('Initializing stream (transcoding audio)...');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(streamUrl);
|
const response = await fetch(streamUrl);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.playlist) {
|
if (data.playlist) {
|
||||||
const playlistUrl = window.location.origin + data.playlist;
|
const playlistUrl = window.location.origin + data.playlist;
|
||||||
log('Got HLS playlist: ' + playlistUrl);
|
log('Got HLS playlist: ' + playlistUrl);
|
||||||
showLoading('Loading HLS stream...');
|
showLoading('Loading HLS stream...');
|
||||||
await playWithHLS(playlistUrl);
|
await playWithHLS(playlistUrl);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
showError('Invalid stream response');
|
showError('Invalid stream response');
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
log('Error fetching playlist: ' + err);
|
|
||||||
showError('Failed to initialize stream');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
log('Error fetching playlist: ' + err);
|
||||||
|
showError('Failed to initialize stream');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user