Refactor video viewer to remove web-specific handling and improve error messaging

This commit is contained in:
Leon Bösche
2026-01-14 11:52:28 +01:00
parent 3757368a00
commit c38ae1bd78
2 changed files with 7 additions and 16 deletions

View File

@@ -1,7 +1,5 @@
// ignore: unused_import
import 'dart:io' show Platform;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'video_viewer_web.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import '../theme/app_theme.dart';
@@ -46,13 +44,6 @@ class _VideoViewerState extends State<VideoViewer> {
@override
Widget build(BuildContext context) {
if (kIsWeb) {
// Use web-specific video viewer
return VideoViewerWeb(
videoUrl: widget.videoUrl,
fileName: widget.fileName,
);
}
return Dialog(
backgroundColor: Colors.transparent,
child: ConstrainedBox(
@@ -85,8 +76,8 @@ class _VideoViewerState extends State<VideoViewer> {
const SizedBox(height: 16),
if (_isError)
const Text(
'Failed to load video',
style: TextStyle(color: Colors.red),
'File type not supported or video could not be loaded',
style: TextStyle(color: AppTheme.primaryText),
)
else if (!_isInitialized)
const Center(

View File

@@ -121,11 +121,11 @@ class FileService {
required String fileId,
String? fileName,
}) async {
// If you have a direct fileId-based endpoint, use it. Otherwise, fallback to path-based if needed.
if (orgId.isEmpty) {
return '/user/files/download?id=${Uri.encodeComponent(fileId)}';
}
return '/orgs/$orgId/files/download?id=${Uri.encodeComponent(fileId)}';
// Return the full download URL
final path = orgId.isEmpty
? '/user/files/download?id=${Uri.encodeComponent(fileId)}'
: '/orgs/$orgId/files/download?id=${Uri.encodeComponent(fileId)}';
return '$baseUrl$path';
}
Future<void> createFolder(