fix: stabilize IPTV playback and implement request throttling

- Add playback lock to XtreamService to delay EPG during stream init
- Increase MPEG-TS stash buffer to 512KB for better stability
- Enable liveBufferLatencyChasing to prevent stream drift
- Tune HLS parameters for balanced speed and reliability
This commit is contained in:
Michael committed 2026-03-10 18:54:44 +01:00
1 parent 0ca6f96710
commit df4bcfd07f
5 files changed
+48 -22

No files matched your search

@@ -140,6 +140,12 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
streamUrl = service.getLiveStreamUrlTs(currentStreamId);
}
// STABILIZATION: Lock background requests during stream init
service.isPlaybackLoading = true;
Future.delayed(const Duration(seconds: 10), () {
service.isPlaybackLoading = false;
});
_currentStreamUrl = streamUrl;
final encodedUrl = Uri.encodeComponent(streamUrl);
@@ -15,6 +15,13 @@ class XtreamService {
PlaylistConfig? _currentPlaylist;
/// Flag to indicate that a playback is currently loading
/// Used to throttle background requests (EPG, images)
bool isPlaybackLoading = false;
/// Minimum delay for background requests when playback is loading
static const _throttleDelay = Duration(seconds: 8);
XtreamService() {
_dio = Dio(
BaseOptions(
@@ -616,6 +623,11 @@ class XtreamService {
Future<List<EpgEntry>> getShortEpg(String streamId) async {
if (_currentPlaylist == null) throw Exception('No playlist configured');
if (isPlaybackLoading) {
debugPrint('[XtreamService] Throttling short EPG for $streamId');
await Future.delayed(_throttleDelay);
}
try {
final response = await _dio.get(
_wrapWithProxy(_currentPlaylist!.apiBaseUrl),
@@ -653,6 +665,11 @@ class XtreamService {
Future<xm.ShortEPG> getShortEPG(String streamId) async {
if (_currentPlaylist == null) throw Exception('No playlist configured');
if (isPlaybackLoading) {
debugPrint('[XtreamService] Throttling short EPG metadata for $streamId');
await Future.delayed(_throttleDelay);
}
try {
final response = await _dio.get(
_wrapWithProxy(_currentPlaylist!.apiBaseUrl),