mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 14: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 {
|
class VideoPlayerWrapper extends StatefulWidget {
|
||||||
final File videoPath;
|
final File videoPath;
|
||||||
|
final bool mirrorVideo;
|
||||||
|
|
||||||
const VideoPlayerWrapper({super.key, required this.videoPath});
|
const VideoPlayerWrapper(
|
||||||
|
{super.key, required this.videoPath, required this.mirrorVideo});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<VideoPlayerWrapper> createState() => _VideoPlayerWrapperState();
|
State<VideoPlayerWrapper> createState() => _VideoPlayerWrapperState();
|
||||||
|
|
@ -21,7 +23,8 @@ class _VideoPlayerWrapperState extends State<VideoPlayerWrapper> {
|
||||||
_controller = VideoPlayerController.file(widget.videoPath)
|
_controller = VideoPlayerController.file(widget.videoPath)
|
||||||
..initialize().then((_) {
|
..initialize().then((_) {
|
||||||
setState(() {
|
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
|
child: _controller.value.isInitialized
|
||||||
? AspectRatio(
|
? AspectRatio(
|
||||||
aspectRatio: _controller.value.aspectRatio,
|
aspectRatio: _controller.value.aspectRatio,
|
||||||
|
child: Transform.flip(
|
||||||
|
flipX: widget.mirrorVideo,
|
||||||
child: VideoPlayer(_controller),
|
child: VideoPlayer(_controller),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: CircularProgressIndicator(), // Show loading indicator while initializing
|
: CircularProgressIndicator(), // Show loading indicator while initializing
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:intl/intl.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:twonly/src/providers/api/media_send.dart' as send;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:photo_view/photo_view.dart';
|
import 'package:photo_view/photo_view.dart';
|
||||||
|
|
@ -18,10 +20,12 @@ class GalleryItem {
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.messages,
|
required this.messages,
|
||||||
required this.date,
|
required this.date,
|
||||||
|
required this.mirrorVideo,
|
||||||
this.imagePath,
|
this.imagePath,
|
||||||
this.videoPath,
|
this.videoPath,
|
||||||
});
|
});
|
||||||
final String id;
|
final String id;
|
||||||
|
final bool mirrorVideo;
|
||||||
final List<Message> messages;
|
final List<Message> messages;
|
||||||
final DateTime date;
|
final DateTime date;
|
||||||
final File? imagePath;
|
final File? imagePath;
|
||||||
|
|
@ -46,6 +50,13 @@ class GalleryItem {
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
bool mirrorVideo = false;
|
||||||
|
if (videoPath != null) {
|
||||||
|
MediaMessageContent content =
|
||||||
|
MediaMessageContent.fromJson(jsonDecode(message.contentJson!));
|
||||||
|
mirrorVideo = content.mirrorVideo;
|
||||||
|
}
|
||||||
|
|
||||||
items
|
items
|
||||||
.putIfAbsent(
|
.putIfAbsent(
|
||||||
id,
|
id,
|
||||||
|
|
@ -53,6 +64,7 @@ class GalleryItem {
|
||||||
id: id.toString(),
|
id: id.toString(),
|
||||||
messages: [],
|
messages: [],
|
||||||
date: message.sendAt,
|
date: message.sendAt,
|
||||||
|
mirrorVideo: mirrorVideo,
|
||||||
imagePath: imagePath,
|
imagePath: imagePath,
|
||||||
videoPath: videoPath))
|
videoPath: videoPath))
|
||||||
.messages
|
.messages
|
||||||
|
|
@ -201,6 +213,7 @@ class GalleryMainViewState extends State<GalleryMainView> {
|
||||||
id: fileName,
|
id: fileName,
|
||||||
messages: [],
|
messages: [],
|
||||||
date: creationDate,
|
date: creationDate,
|
||||||
|
mirrorVideo: false,
|
||||||
imagePath: imagePath,
|
imagePath: imagePath,
|
||||||
videoPath: videoPath,
|
videoPath: videoPath,
|
||||||
));
|
));
|
||||||
|
|
@ -399,7 +412,10 @@ class _GalleryPhotoViewWrapperState extends State<GalleryPhotoViewWrapper> {
|
||||||
final GalleryItem item = widget.galleryItems[index];
|
final GalleryItem item = widget.galleryItems[index];
|
||||||
return item.videoPath != null
|
return item.videoPath != null
|
||||||
? PhotoViewGalleryPageOptions.customChild(
|
? PhotoViewGalleryPageOptions.customChild(
|
||||||
child: VideoPlayerWrapper(videoPath: item.videoPath!),
|
child: VideoPlayerWrapper(
|
||||||
|
videoPath: item.videoPath!,
|
||||||
|
mirrorVideo: item.mirrorVideo,
|
||||||
|
),
|
||||||
// childSize: const Size(300, 300),
|
// childSize: const Size(300, 300),
|
||||||
initialScale: PhotoViewComputedScale.contained,
|
initialScale: PhotoViewComputedScale.contained,
|
||||||
minScale: PhotoViewComputedScale.contained,
|
minScale: PhotoViewComputedScale.contained,
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ class HomeViewState extends State<HomeView> {
|
||||||
selectCamera(selectedCameraDetails.cameraId, false, false);
|
selectCamera(selectedCameraDetails.cameraId, false, false);
|
||||||
}
|
}
|
||||||
if (offsetRatio == 1) {
|
if (offsetRatio == 1) {
|
||||||
disableCameraTimer = Timer(Duration(seconds: 2), () {
|
disableCameraTimer = Timer(Duration(seconds: 1), () {
|
||||||
cameraController?.dispose();
|
cameraController?.dispose();
|
||||||
cameraController = null;
|
cameraController = null;
|
||||||
disableCameraTimer = null;
|
disableCameraTimer = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue