mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 16:48:41 +00:00
fix #163
This commit is contained in:
parent
98078c5220
commit
62e74c604a
1 changed files with 12 additions and 5 deletions
|
|
@ -20,6 +20,8 @@ import 'package:twonly/src/utils/storage.dart';
|
||||||
import 'package:twonly/src/views/camera/share_image_editor_view.dart';
|
import 'package:twonly/src/views/camera/share_image_editor_view.dart';
|
||||||
import 'package:twonly/src/views/home_view.dart';
|
import 'package:twonly/src/views/home_view.dart';
|
||||||
|
|
||||||
|
int maxVideoRecordingTime = 15;
|
||||||
|
|
||||||
class CameraPreviewView extends StatefulWidget {
|
class CameraPreviewView extends StatefulWidget {
|
||||||
const CameraPreviewView({super.key, this.sendTo});
|
const CameraPreviewView({super.key, this.sendTo});
|
||||||
final Contact? sendTo;
|
final Contact? sendTo;
|
||||||
|
|
@ -92,8 +94,11 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future selectCamera(int sCameraId,
|
Future selectCamera(
|
||||||
{bool init = false, bool enableAudio = false}) async {
|
int sCameraId, {
|
||||||
|
bool init = false,
|
||||||
|
bool enableAudio = false,
|
||||||
|
}) async {
|
||||||
if (sCameraId >= gCameras.length) return;
|
if (sCameraId >= gCameras.length) return;
|
||||||
if (init) {
|
if (init) {
|
||||||
for (; sCameraId < gCameras.length; sCameraId++) {
|
for (; sCameraId < gCameras.length; sCameraId++) {
|
||||||
|
|
@ -104,6 +109,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
isZoomAble = false;
|
isZoomAble = false;
|
||||||
|
scaleFactor = 1;
|
||||||
});
|
});
|
||||||
controller = CameraController(
|
controller = CameraController(
|
||||||
gCameras[sCameraId],
|
gCameras[sCameraId],
|
||||||
|
|
@ -320,13 +326,14 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await controller?.startVideoRecording();
|
await controller?.startVideoRecording();
|
||||||
videoRecordingTimer = Timer.periodic(Duration(milliseconds: 10), (timer) {
|
videoRecordingTimer = Timer.periodic(Duration(milliseconds: 15), (timer) {
|
||||||
setState(() {
|
setState(() {
|
||||||
currentTime = DateTime.now();
|
currentTime = DateTime.now();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (videoRecordingStarted != null &&
|
if (videoRecordingStarted != null &&
|
||||||
currentTime.difference(videoRecordingStarted!).inSeconds >= 10) {
|
currentTime.difference(videoRecordingStarted!).inSeconds >=
|
||||||
|
maxVideoRecordingTime) {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
videoRecordingTimer = null;
|
videoRecordingTimer = null;
|
||||||
stopVideoRecording();
|
stopVideoRecording();
|
||||||
|
|
@ -636,7 +643,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
value:
|
value:
|
||||||
(currentTime.difference(videoRecordingStarted!))
|
(currentTime.difference(videoRecordingStarted!))
|
||||||
.inMilliseconds /
|
.inMilliseconds /
|
||||||
(10 * 1000),
|
(maxVideoRecordingTime * 1000),
|
||||||
strokeWidth: 4,
|
strokeWidth: 4,
|
||||||
valueColor:
|
valueColor:
|
||||||
AlwaysStoppedAnimation<Color>(Colors.red),
|
AlwaysStoppedAnimation<Color>(Colors.red),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue