video_editor_plus 0.0.1
video_editor_plus: ^0.0.1 copied to clipboard
Video trimmer, with multi audio track mixing and trimming.
example/main.dart
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:video_editor_plus/video_editor_plus.dart';
import 'package:video_player/video_player.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Video Trimmer',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Video Trimmer"),
),
body: Center(
child: ElevatedButton(
child: const Text("LOAD VIDEO"),
onPressed: () async {
var result = await FilePicker.platform.pickFiles(
type: FileType.video,
allowCompression: false,
);
if (result != null) {
File file = File(result.files.single.path!);
Navigator.of(context).push(
MaterialPageRoute(builder: (context) {
return VideoEditorPlus(
file,
maxVideoLength: const Duration(seconds: 40),
);
}),
);
}
},
),
),
);
}
}
class Preview extends StatefulWidget {
final String? outputVideoPath;
const Preview(this.outputVideoPath, {super.key});
@override
State<Preview> createState() => _PreviewState();
}
class _PreviewState extends State<Preview> {
late VideoPlayerController _controller;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.file(File(widget.outputVideoPath!))
..initialize().then((_) {
setState(() {});
_controller.play();
});
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: const Text("Preview"),
),
body: Center(
child: AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: _controller.value.isInitialized
? VideoPlayer(_controller)
: const Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
),
),
),
),
);
}
}