Add web-specific video viewer and update video player initialization
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
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';
|
||||||
@@ -24,7 +27,7 @@ class _VideoViewerState extends State<VideoViewer> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_controller = VideoPlayerController.network(widget.videoUrl)
|
_controller = VideoPlayerController.networkUrl(Uri.parse(widget.videoUrl))
|
||||||
..initialize()
|
..initialize()
|
||||||
.then((_) {
|
.then((_) {
|
||||||
if (mounted) setState(() => _isInitialized = true);
|
if (mounted) setState(() => _isInitialized = true);
|
||||||
@@ -42,6 +45,13 @@ 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(
|
||||||
@@ -94,11 +104,11 @@ class _VideoViewerState extends State<VideoViewer> {
|
|||||||
allowScrubbing: true,
|
allowScrubbing: true,
|
||||||
colors: VideoProgressColors(
|
colors: VideoProgressColors(
|
||||||
playedColor: AppTheme.accentColor,
|
playedColor: AppTheme.accentColor,
|
||||||
backgroundColor: AppTheme.secondaryText.withOpacity(
|
backgroundColor: AppTheme.secondaryText.withValues(
|
||||||
0.2,
|
alpha: 0.2,
|
||||||
),
|
),
|
||||||
bufferedColor: AppTheme.secondaryText.withOpacity(
|
bufferedColor: AppTheme.secondaryText.withValues(
|
||||||
0.5,
|
alpha: 0.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -130,7 +140,7 @@ class _ControlsOverlay extends StatelessWidget {
|
|||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.play_arrow,
|
Icons.play_arrow,
|
||||||
size: 64,
|
size: 64,
|
||||||
color: AppTheme.accentColor.withOpacity(0.8),
|
color: AppTheme.accentColor.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
60
b0esche_cloud/lib/pages/video_viewer_web.dart
Normal file
60
b0esche_cloud/lib/pages/video_viewer_web.dart
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class VideoViewerWeb extends StatelessWidget {
|
||||||
|
final String videoUrl;
|
||||||
|
final String fileName;
|
||||||
|
|
||||||
|
const VideoViewerWeb({
|
||||||
|
super.key,
|
||||||
|
required this.videoUrl,
|
||||||
|
required this.fileName,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 700, maxHeight: 500),
|
||||||
|
child: Container(
|
||||||
|
decoration: AppTheme.glassDecoration,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
fileName,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: AppTheme.primaryText,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close, color: AppTheme.primaryText),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
child: HtmlElementView(viewType: videoUrl),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user