fix(mobile): fix orientation reset with IndexedStack, support HLS in Lite player, and optimize fullscreen

This commit is contained in:
Michael committed 2026-03-09 21:35:00 +01:00
1 parent 39f4205d68
commit 441597354e
3 files changed
+46 -35

No files matched your search

+24 -5
View File
@@ -285,17 +285,36 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
void _toggleFullscreen() {
try {
if (html.document.fullscreenElement != null) {
html.document.exitFullscreen();
final doc = html.document;
final isFullscreen = doc.fullscreenElement != null ||
(doc as dynamic).webkitFullscreenElement != null ||
(doc as dynamic).mozFullScreenElement != null;
if (isFullscreen) {
if (doc.exitFullscreen != null) {
doc.exitFullscreen();
} else if ((doc as dynamic).webkitExitFullscreen != null) {
(doc as dynamic).webkitExitFullscreen();
} else if ((doc as dynamic).mozCancelFullScreen != null) {
(doc as dynamic).mozCancelFullScreen();
}
} else {
final element = html.document.documentElement;
final element = doc.documentElement;
if (element != null) {
element.requestFullscreen();
if (element.requestFullscreen != null) {
element.requestFullscreen();
} else if ((element as dynamic).webkitRequestFullscreen != null) {
(element as dynamic).webkitRequestFullscreen();
} else if ((element as dynamic).mozRequestFullScreen != null) {
(element as dynamic).mozRequestFullScreen();
} else {
// Fallback: Message the player if browser API fails
_sendMessage({'type': 'request_fullscreen'});
}
}
}
} catch (e) {
print('[PlayerScreen] Fullscreen error: $e');
// Fallback: Message the player to try internal fullscreen
_sendMessage({'type': 'request_fullscreen'});
}
}
@@ -25,25 +25,6 @@ class _MobileDashboardScreenState extends ConsumerState<MobileDashboardScreen> {
@override
Widget build(BuildContext context) {
// Determine which tab to show
Widget currentTab;
switch (_currentIndex) {
case 0:
currentTab = MobileLiveTVTab(playlist: widget.playlist);
break;
case 1:
currentTab = MobileMoviesTab(playlist: widget.playlist);
break;
case 2:
currentTab = MobileSeriesTab(playlist: widget.playlist);
break;
case 3:
currentTab = const MobileSettingsTab();
break;
default:
currentTab = MobileLiveTVTab(playlist: widget.playlist);
}
return Theme(
data: MobileTheme.darkTheme,
child: MobileScaffold(
@@ -53,7 +34,15 @@ class _MobileDashboardScreenState extends ConsumerState<MobileDashboardScreen> {
_currentIndex = index;
});
},
child: currentTab,
child: IndexedStack(
index: _currentIndex,
children: [
MobileLiveTVTab(playlist: widget.playlist),
MobileMoviesTab(playlist: widget.playlist),
MobileSeriesTab(playlist: widget.playlist),
const MobileSettingsTab(),
],
),
),
);
}
+13 -10
View File
@@ -452,11 +452,16 @@
log('Stream type: ' + streamType);
const lowerUrl = streamUrl.toLowerCase();
// LIVE TV: Direct MPEG-TS playback with mpegts.js
// LIVE TV: Try HLS first if URL contains m3u8, otherwise mpegts
if (streamType === 'live') {
log('Live TV mode - using mpegts.js direct');
showLoading('Connecting to live stream...');
await playWithMpegTS(streamUrl, true);
if (lowerUrl.includes('.m3u8') || lowerUrl.includes('/playlist.m3u8')) {
log('Live TV mode - HLS detected, using HLS.js');
await playWithHLS(streamUrl);
} else {
log('Live TV mode - using mpegts.js direct');
showLoading('Connecting to live stream...');
await playWithMpegTS(streamUrl, true);
}
return;
}
@@ -500,12 +505,10 @@
video.currentTime = parseFloat(data.value);
}
} else if (data.type === 'request_fullscreen') {
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen();
} else if (video.msRequestFullscreen) {
video.msRequestFullscreen();
const el = document.documentElement;
const requestMethod = el.requestFullscreen || el.webkitRequestFullscreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;
if (requestMethod) {
requestMethod.call(el).catch(e => log('Fullscreen error: ' + e));
}
}
});