mirror of
https://github.com/stonega/tsacdop
synced 2024-12-17 18:59:47 +01:00
70 lines
1.9 KiB
Dart
70 lines
1.9 KiB
Dart
|
import 'dart:io';
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/services.dart';
|
||
|
import 'package:video_player/video_player.dart';
|
||
|
|
||
|
import '../util/context_extension.dart';
|
||
|
|
||
|
class ClipPreview extends StatefulWidget {
|
||
|
final String filePath;
|
||
|
ClipPreview({this.filePath, Key key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_ClipPreviewState createState() => _ClipPreviewState();
|
||
|
}
|
||
|
|
||
|
class _ClipPreviewState extends State<ClipPreview> {
|
||
|
VideoPlayerController _controller;
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
_controller = VideoPlayerController.file(File(widget.filePath))
|
||
|
..initialize().then((_) {
|
||
|
setState(() {});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void dispose() {
|
||
|
super.dispose();
|
||
|
_controller.dispose();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||
|
value: SystemUiOverlayStyle(
|
||
|
statusBarIconBrightness: Brightness.light,
|
||
|
systemNavigationBarColor: Colors.black,
|
||
|
systemNavigationBarIconBrightness: Brightness.dark,
|
||
|
),
|
||
|
child: Scaffold(
|
||
|
appBar: AppBar(backgroundColor: Colors.black),
|
||
|
backgroundColor: Colors.black,
|
||
|
body: Center(
|
||
|
child: _controller.value.initialized
|
||
|
? AspectRatio(
|
||
|
aspectRatio: _controller.value.aspectRatio,
|
||
|
child: VideoPlayer(_controller),
|
||
|
)
|
||
|
: Container(),
|
||
|
),
|
||
|
floatingActionButton: FloatingActionButton(
|
||
|
backgroundColor: context.accentColor,
|
||
|
onPressed: () {
|
||
|
setState(() {
|
||
|
_controller.value.isPlaying
|
||
|
? _controller.pause()
|
||
|
: _controller.play();
|
||
|
});
|
||
|
},
|
||
|
child: Icon(
|
||
|
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|