mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 12:48:41 +00:00
mirrorVideo
This commit is contained in:
parent
9a06271140
commit
3ef585f8d4
3 changed files with 27 additions and 5 deletions
|
|
@ -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<VideoPlayerWrapper> createState() => _VideoPlayerWrapperState();
|
||||
|
|
@ -21,7 +23,8 @@ class _VideoPlayerWrapperState extends State<VideoPlayerWrapper> {
|
|||
_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<VideoPlayerWrapper> {
|
|||
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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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<Message> 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<GalleryMainView> {
|
|||
id: fileName,
|
||||
messages: [],
|
||||
date: creationDate,
|
||||
mirrorVideo: false,
|
||||
imagePath: imagePath,
|
||||
videoPath: videoPath,
|
||||
));
|
||||
|
|
@ -399,7 +412,10 @@ class _GalleryPhotoViewWrapperState extends State<GalleryPhotoViewWrapper> {
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class HomeViewState extends State<HomeView> {
|
|||
selectCamera(selectedCameraDetails.cameraId, false, false);
|
||||
}
|
||||
if (offsetRatio == 1) {
|
||||
disableCameraTimer = Timer(Duration(seconds: 2), () {
|
||||
disableCameraTimer = Timer(Duration(seconds: 1), () {
|
||||
cameraController?.dispose();
|
||||
cameraController = null;
|
||||
disableCameraTimer = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue