mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
feat: implement Turbo-Start stream acceleration
- Add direct MPEG-TS support and optimized HLS tuning - Implement low-latency sync and instant bitrate selection - Achieve TiviMate-like zapping speed by reducing initial buffers
This commit is contained in:
1 parent
736ab0f51c
commit
0ca6f96710
5 files changed
+67
-18
No files matched your search
@@ -132,20 +132,29 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
}
|
||||
|
||||
// Store URL for Lite Player
|
||||
final isMobile = MediaQuery.of(context).size.width < 600;
|
||||
final isLiveTV = widget.streamType == StreamType.live;
|
||||
|
||||
// TURBO-START: Use direct MPEG-TS for Live TV on Desktop/Android for instant zapping
|
||||
if (isLiveTV && !isMobile) {
|
||||
streamUrl = service.getLiveStreamUrlTs(currentStreamId);
|
||||
}
|
||||
|
||||
_currentStreamUrl = streamUrl;
|
||||
|
||||
final encodedUrl = Uri.encodeComponent(streamUrl);
|
||||
// Force player choice based on stream type:
|
||||
// - Live TV: Player Lite (simple TS playback with mpegts.js)
|
||||
// - VOD/Series: Player Standard (fuller controls, HLS support)
|
||||
final isMobile = MediaQuery.of(context).size.width < 600;
|
||||
final isLiveTV = widget.streamType == StreamType.live;
|
||||
|
||||
// Cache buster to force reload of updated player.html
|
||||
final cacheBuster = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
final streamTypeParam = widget.streamType == StreamType.live ? 'live' : 'vod';
|
||||
final playerFile = isMobile ? 'player_mobile.html' : (isLiveTV ? 'player_lite.html' : 'player.html');
|
||||
var playerSrc = '$playerFile?url=$encodedUrl&type=$streamTypeParam&v=$cacheBuster';
|
||||
|
||||
// Inject Turbo-Start flag
|
||||
var playerSrc = '$playerFile?url=$encodedUrl&type=$streamTypeParam&turbo=true&v=$cacheBuster';
|
||||
|
||||
if (startTimeOverride != null) {
|
||||
playerSrc += '&t=$startTimeOverride';
|
||||
|
||||
@@ -89,13 +89,24 @@ class XtreamService {
|
||||
_currentPlaylist = playlist;
|
||||
}
|
||||
|
||||
/// Generate stream URL for live TV
|
||||
/// Generate stream URL for live TV (HLS)
|
||||
String getLiveStreamUrl(String streamId) {
|
||||
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||
// Use HLS (.m3u8) with a subpath to ensure relative segments resolve correctly
|
||||
return '$_backendBaseUrl/api/live/$streamId/playlist.m3u8';
|
||||
}
|
||||
|
||||
/// Generate stream URL for live TV (Direct MPEG-TS)
|
||||
/// Faster zapping on compatible players (mpegts.js)
|
||||
String getLiveStreamUrlTs(String streamId) {
|
||||
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||
// Direct link to the .ts stream through our proxy
|
||||
final dns = _currentPlaylist!.dns;
|
||||
final user = _currentPlaylist!.username;
|
||||
final pass = _currentPlaylist!.password;
|
||||
final url = '$dns/live/$user/$pass/$streamId.ts';
|
||||
return '$_backendBaseUrl/api/xtream/${Uri.encodeComponent(url)}';
|
||||
}
|
||||
|
||||
/// Generate stream URL for VOD (movies)
|
||||
String getVodStreamUrl(String streamId, String containerExtension) {
|
||||
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||
|
||||
Reference in new issue
Block a user