12345678910111213141516171819202122232425262728293031323334353637383940 |
- import 'package:flutter/material.dart';
- import 'package:video_player/video_player.dart';
- class YSVideoView extends StatefulWidget {
- final VideoPlayerController player;
- const YSVideoView({Key? key, required this.player}) : super(key: key);
- @override
- YSVideoViewState createState() => YSVideoViewState();
- }
- class YSVideoViewState extends State<YSVideoView> {
- @override
- Widget build(BuildContext context) {
- return ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(50)),
- child: GestureDetector(
- onLongPressStart: (value){
- widget.player.setPlaybackSpeed(2);
- },
- onLongPressEnd: (value){
- widget.player.setPlaybackSpeed(1);
- },
- onHorizontalDragEnd: (value){
- int seconds1 = widget.player.value.position.inSeconds;
- int seconds2 = widget.player.value.duration.inSeconds;
- int velocity = (value.primaryVelocity??0.0)~/100;
- int number = (seconds2/100*velocity)~/1;
- // LogUtil.d('$seconds1=======$seconds2=======$velocity=======$number');
- if(seconds1<=1)return;
- widget.player.seekTo(Duration(seconds: seconds1+number));
- },
- child: Container(
- color: Colors.white,
- child: VideoPlayer(widget.player),
- ),
- ),
- );
- }
- }
|