mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-23 15:08:07 +02:00
feat: Add IPTV player HTML pages with HLS/MPEG-TS support and parent communication.
This commit is contained in:
1 parent
b2298a9bf4
commit
781f58cb38
2 files changed
+56
-36
No files matched your search
+29
-17
@@ -511,28 +511,40 @@
|
|||||||
|
|
||||||
log('Stream URL: ' + streamUrl.substring(0, 80) + '...');
|
log('Stream URL: ' + streamUrl.substring(0, 80) + '...');
|
||||||
|
|
||||||
// SPECIAL: /api/stream/ returns JSON with HLS playlist URL
|
// SPECIAL: /api/stream/ endpoint - differentiate Live vs VOD
|
||||||
if (streamUrl.includes('/api/stream/')) {
|
if (streamUrl.includes('/api/stream/')) {
|
||||||
log('Detected /api/stream/ - fetching HLS playlist...');
|
// Check if this is a live stream (URL param check since player.html doesn't have type param by default)
|
||||||
showLoading('Initializing stream (transcoding audio)...');
|
const isLiveStream = streamUrl.includes('live') || urlParams.get('type') === 'live';
|
||||||
|
|
||||||
try {
|
if (isLiveStream) {
|
||||||
const response = await fetch(streamUrl);
|
// LIVE TV: Use MPEG-TS direct streaming
|
||||||
const data = await response.json();
|
log('Live TV via /api/stream/ - using MPEG-TS');
|
||||||
|
showLoading('Connecting to live stream...');
|
||||||
|
await playWithMpegTS(streamUrl);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// VOD: Fetch JSON to get HLS playlist (transcoding mode)
|
||||||
|
log('VOD via /api/stream/ - fetching HLS...');
|
||||||
|
showLoading('Initializing stream (transcoding audio)...');
|
||||||
|
|
||||||
if (data.playlist) {
|
try {
|
||||||
const playlistUrl = window.location.origin + data.playlist;
|
const response = await fetch(streamUrl);
|
||||||
log('Playing HLS: ' + playlistUrl);
|
const data = await response.json();
|
||||||
await playWithHLS(playlistUrl);
|
|
||||||
return;
|
if (data.playlist) {
|
||||||
} else {
|
const playlistUrl = window.location.origin + data.playlist;
|
||||||
showError('Invalid stream response');
|
log('Playing HLS: ' + playlistUrl);
|
||||||
|
await playWithHLS(playlistUrl);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
showError('Invalid stream response');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
log('Error: ' + err);
|
||||||
|
showError('Stream init failed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
log('Error: ' + err);
|
|
||||||
showError('Stream init failed');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+27
-19
@@ -361,30 +361,38 @@
|
|||||||
log('Stream type: ' + streamType);
|
log('Stream type: ' + streamType);
|
||||||
const lowerUrl = streamUrl.toLowerCase();
|
const lowerUrl = streamUrl.toLowerCase();
|
||||||
|
|
||||||
// SPECIAL: /api/stream/ endpoint returns JSON with HLS playlist URL
|
// SPECIAL: /api/stream/ endpoint handling - differentiate Live vs VOD
|
||||||
if (streamUrl.includes('/api/stream/')) {
|
if (streamUrl.includes('/api/stream/')) {
|
||||||
log('Detected /api/stream/ - fetching HLS playlist URL...');
|
if (streamType === 'live') {
|
||||||
showLoading('Initializing stream (transcoding audio)...');
|
// LIVE TV: Use MPEG-TS direct streaming
|
||||||
|
log('Live TV via /api/stream/ - using MPEG-TS direct');
|
||||||
|
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 {
|
||||||
// Fetch JSON response to get playlist URL
|
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