handle offline channels gracefully in native video player

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tommy Chow 2026-03-08 16:42:39 -07:00
parent 1779520db8
commit 418c51ce6d
3 changed files with 23 additions and 4 deletions

View file

@ -17,11 +17,14 @@ class NativeVideo extends StatelessWidget {
final controller = nativeVideoStore.controller;
final error = nativeVideoStore.error;
final isOffline =
nativeVideoStore.streamInfo == null && error == null;
return ColoredBox(
color: Colors.black,
child: Stack(
children: [
if (controller != null)
if (controller != null && !isOffline)
NativeVideoPlayer(
key: ObjectKey(controller),
controller: controller,
@ -37,6 +40,17 @@ class NativeVideo extends StatelessWidget {
),
),
),
if (isOffline)
const Center(
child: Text(
'Offline',
style: TextStyle(
color: Colors.white38,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
],
),
);

View file

@ -185,9 +185,15 @@ abstract class NativeVideoStoreBase with Store implements VideoPlayerInterface {
_error = null;
});
} catch (e) {
// Wait for stream info so we can distinguish "offline" from "broken".
await updateStreamInfo();
runInAction(() {
_error =
'Native player failed to load. Try the standard player in Settings.';
// Only show the error if the stream is actually live — an offline
// channel is expected to fail here and the overlay handles it.
if (_streamInfo != null) {
_error =
'Native player failed to load. Try the standard player in Settings.';
}
});
debugPrint('NativeVideoStore init error: $e');
}

View file

@ -260,7 +260,6 @@ class VideoOverlay extends StatelessWidget {
displayName: chatStore.displayName,
showUptime: false,
showViewerCount: false,
showOfflineIndicator: false,
textColor: surfaceColor,
isOffline: true,
isInSharedChatMode: