lukas-heiligenbrunner
5fc77b4abb
cache previews in sqlite db actor page outsouce different players in seperate classes
60 lines
1.5 KiB
Dart
60 lines
1.5 KiB
Dart
import 'package:chewie/chewie.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:video_player/video_player.dart';
|
|
|
|
class VideoScreenMobile extends StatefulWidget {
|
|
const VideoScreenMobile({Key? key, required this.url}) : super(key: key);
|
|
final String url;
|
|
|
|
@override
|
|
State<VideoScreenMobile> createState() => _VideoScreenMobileState();
|
|
}
|
|
|
|
class _VideoScreenMobileState extends State<VideoScreenMobile> {
|
|
ChewieController? _chewieController;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_chewieController == null) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: const [CircularProgressIndicator(), Text("loading...")],
|
|
);
|
|
}
|
|
return Chewie(
|
|
controller: _chewieController!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
_chewieController?.videoPlayerController.dispose();
|
|
_chewieController?.dispose();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_init();
|
|
}
|
|
|
|
void _init() async {
|
|
final VideoPlayerController _controller =
|
|
VideoPlayerController.network(widget.url);
|
|
await _controller.initialize();
|
|
|
|
_chewieController = ChewieController(
|
|
videoPlayerController: _controller,
|
|
autoPlay: true,
|
|
looping: true,
|
|
allowFullScreen: true,
|
|
allowMuting: true,
|
|
allowPlaybackSpeedChanging: true,
|
|
zoomAndPan: true);
|
|
|
|
setState(() {});
|
|
}
|
|
}
|