Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/src/trim_editor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -242,6 +243,8 @@ class _TrimEditorState extends State<TrimEditor> with TickerProviderStateMixin {
AnimationController _animationController;
Tween<double> _linearTween;

final _refreshVideoDuration = Duration(milliseconds: 50);

Future<void> _initializeVideoController() async {
if (_videoFile != null) {
videoPlayerController.addListener(() {
Expand Down Expand Up @@ -334,7 +337,7 @@ class _TrimEditorState extends State<TrimEditor> with TickerProviderStateMixin {
_refreshEnd();
});
await videoPlayerController.pause();
await videoPlayerController.seekTo(Duration(milliseconds: _videoEndPos.toInt()));
await videoPlayerController.seekTo(Duration(milliseconds: _videoEndPos.toInt()) - _refreshVideoDuration);
_linearTween.end = _endPos.dx;
_animationController.duration = Duration(milliseconds: (_videoEndPos - _videoStartPos).toInt());
_animationController.reset();
Expand Down Expand Up @@ -471,10 +474,11 @@ class _TrimEditorState extends State<TrimEditor> with TickerProviderStateMixin {
}
}
},
onHorizontalDragEnd: (DragEndDetails details) {
onHorizontalDragEnd: (DragEndDetails details) async {
setState(() {
_circleSize = widget.circleSize;
});
await _refreshVideoIfNeeded();
},
onHorizontalDragUpdate: (DragUpdateDetails details) {
_circleSize = widget.circleSizeOnDrag;
Expand Down Expand Up @@ -552,4 +556,13 @@ class _TrimEditorState extends State<TrimEditor> with TickerProviderStateMixin {
),
);
}

_refreshVideoIfNeeded() async {
if (Platform.isIOS) {
await videoPlayerController.play();
Timer(_refreshVideoDuration, () {
videoPlayerController.pause();
});
}
}
}