diff --git a/lib/src/views/components/video_player_wrapper.dart b/lib/src/views/components/video_player_wrapper.dart index a93b482..b4f5ef6 100644 --- a/lib/src/views/components/video_player_wrapper.dart +++ b/lib/src/views/components/video_player_wrapper.dart @@ -5,8 +5,10 @@ import 'package:video_player/video_player.dart'; class VideoPlayerWrapper extends StatefulWidget { final File videoPath; + final bool mirrorVideo; - const VideoPlayerWrapper({super.key, required this.videoPath}); + const VideoPlayerWrapper( + {super.key, required this.videoPath, required this.mirrorVideo}); @override State createState() => _VideoPlayerWrapperState(); @@ -21,7 +23,8 @@ class _VideoPlayerWrapperState extends State { _controller = VideoPlayerController.file(widget.videoPath) ..initialize().then((_) { setState(() { - _controller.play(); // Auto-play the video + _controller.setLooping(true); + _controller.play(); }); }); } @@ -38,7 +41,10 @@ class _VideoPlayerWrapperState extends State { child: _controller.value.isInitialized ? AspectRatio( aspectRatio: _controller.value.aspectRatio, - child: VideoPlayer(_controller), + child: Transform.flip( + flipX: widget.mirrorVideo, + child: VideoPlayer(_controller), + ), ) : CircularProgressIndicator(), // Show loading indicator while initializing ); diff --git a/lib/src/views/gallery/gallery_main_view.dart b/lib/src/views/gallery/gallery_main_view.dart index 183bf3d..c72ec44 100644 --- a/lib/src/views/gallery/gallery_main_view.dart +++ b/lib/src/views/gallery/gallery_main_view.dart @@ -1,6 +1,8 @@ +import 'dart:convert'; import 'dart:io'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:intl/intl.dart'; +import 'package:twonly/src/model/json/message.dart'; import 'package:twonly/src/providers/api/media_send.dart' as send; import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; @@ -18,10 +20,12 @@ class GalleryItem { required this.id, required this.messages, required this.date, + required this.mirrorVideo, this.imagePath, this.videoPath, }); final String id; + final bool mirrorVideo; final List messages; final DateTime date; final File? imagePath; @@ -46,6 +50,13 @@ class GalleryItem { } else { continue; } + bool mirrorVideo = false; + if (videoPath != null) { + MediaMessageContent content = + MediaMessageContent.fromJson(jsonDecode(message.contentJson!)); + mirrorVideo = content.mirrorVideo; + } + items .putIfAbsent( id, @@ -53,6 +64,7 @@ class GalleryItem { id: id.toString(), messages: [], date: message.sendAt, + mirrorVideo: mirrorVideo, imagePath: imagePath, videoPath: videoPath)) .messages @@ -201,6 +213,7 @@ class GalleryMainViewState extends State { id: fileName, messages: [], date: creationDate, + mirrorVideo: false, imagePath: imagePath, videoPath: videoPath, )); @@ -399,7 +412,10 @@ class _GalleryPhotoViewWrapperState extends State { final GalleryItem item = widget.galleryItems[index]; return item.videoPath != null ? PhotoViewGalleryPageOptions.customChild( - child: VideoPlayerWrapper(videoPath: item.videoPath!), + child: VideoPlayerWrapper( + videoPath: item.videoPath!, + mirrorVideo: item.mirrorVideo, + ), // childSize: const Size(300, 300), initialScale: PhotoViewComputedScale.contained, minScale: PhotoViewComputedScale.contained, diff --git a/lib/src/views/home_view.dart b/lib/src/views/home_view.dart index b91897d..e7c3606 100644 --- a/lib/src/views/home_view.dart +++ b/lib/src/views/home_view.dart @@ -73,7 +73,7 @@ class HomeViewState extends State { selectCamera(selectedCameraDetails.cameraId, false, false); } if (offsetRatio == 1) { - disableCameraTimer = Timer(Duration(seconds: 2), () { + disableCameraTimer = Timer(Duration(seconds: 1), () { cameraController?.dispose(); cameraController = null; disableCameraTimer = null;