Skip to content

Commit

Permalink
image_manager: do not play any sound when previewing videos
Browse files Browse the repository at this point in the history
  • Loading branch information
resucutie committed Nov 17, 2024
1 parent a4a987d commit 93cf3ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/components/image_grid_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class _ImageGridState extends State<ImageGrid> {

String getType(String filename) {
final mime = lookupMimeType(filename)!;
debugPrint(mime);
if(mime.startsWith("video")) return "video";
if(mime.startsWith("image/gif")) return "gif";
return "image";
Expand Down
7 changes: 5 additions & 2 deletions lib/components/video_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class VideoView extends StatefulWidget {
const VideoView(this.path, {super.key, this.showControls = true});
const VideoView(this.path, {super.key, this.showControls = true, this.soundOnStart = true, this.playOnStart = true});

final String path;
final bool showControls;
final bool soundOnStart;
final bool playOnStart;

@override
State<VideoView> createState() => VideoViewState();
Expand All @@ -28,11 +30,12 @@ class VideoViewState extends State<VideoView> {
..initialize().then((value) {
_chewieController = ChewieController(
videoPlayerController: _videoController,
autoPlay: true,
autoPlay: widget.playOnStart,
looping: true,
allowFullScreen: false, // apparently full screen calls dispose()
showControls: widget.showControls
);
if(!widget.soundOnStart) _videoController.setVolume(0);
setState(() {
_isLoaded = true;
});
Expand Down
4 changes: 3 additions & 1 deletion lib/views/image_manager/components/image_upload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class ImageUploadForm extends StatelessWidget {
if(state.value.isEmpty) {
return const Icon(Icons.add);
} else {
if(lookupMimeType(state.value)!.startsWith("video/")) return IgnorePointer(child: VideoView(state.value, showControls: false,),);
if(lookupMimeType(state.value)!.startsWith("video/")) return IgnorePointer(
child: VideoView(state.value, showControls: false, soundOnStart: false,),
);
return Image(
image: ResizeImage(
FileImage(File(state.value)),
Expand Down

0 comments on commit 93cf3ec

Please sign in to comment.