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

View File

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