Enhance video file handling in file explorer; implement viewer session for authenticated URL and improve error handling for missing file ID.
This commit is contained in:
@@ -901,15 +901,26 @@ class _FileExplorerState extends State<FileExplorer> {
|
||||
if (file.type == FileType.folder) {
|
||||
context.read<FileBrowserBloc>().add(NavigateToFolder(file.path));
|
||||
} else if (isVideo) {
|
||||
// Open video files in video viewer
|
||||
final videoUrl = await getIt<FileService>().getDownloadUrl(
|
||||
widget.orgId,
|
||||
file.path,
|
||||
);
|
||||
_showVideoViewer(
|
||||
file.name,
|
||||
'${getIt<FileService>().baseUrl}$videoUrl',
|
||||
);
|
||||
// Open video files in video viewer - use viewer session for authenticated URL
|
||||
if (file.id == null || file.id!.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Error: File ID is missing')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final session = await getIt<FileService>().requestViewerSession(
|
||||
widget.orgId,
|
||||
file.id!,
|
||||
);
|
||||
_showVideoViewer(file.name, session.viewUrl.toString());
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error loading video: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (file.id == null || file.id!.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
||||
Reference in New Issue
Block a user