1
0
mirror of https://github.com/stonega/tsacdop synced 2024-12-17 18:59:47 +01:00
tsacdop-podcast-app-android/lib/home/preview.dart

70 lines
1.9 KiB
Dart
Raw Normal View History

2020-05-18 19:03:45 +02:00
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,
),
),
),
);
}
}