Creada una versión super básica del conversor

parent 9d1ad18c
import 'package:ffmpeg_kit_flutter/ffmpeg_kit.dart';
import 'package:ffmpeg_kit_flutter/ffmpeg_session.dart';
import 'package:ffmpeg_kit_flutter/return_code.dart';
import 'package:prueba_multimedia/modelo/modelo.dart';
// TODO: TERMINAR
abstract class Conversor {
/// Se llama una vez el usuario pulsa convertir
static Future<ReturnCode?> convertir(Archivo archivo) async {
archivo.formatoDestino = Formato.jpg;
String path = archivo.file.path;
String nuevoPath = "/storage/emulated/0/Documents/${archivo.nombre}.${archivo.formatoDestino!.name}";
String comando = "-i $path $nuevoPath";
FFmpegSession session = await FFmpegKit.execute(comando);
ReturnCode? returnCode = await session.getReturnCode();
return returnCode;
}
}
\ No newline at end of file
......@@ -5,4 +5,5 @@ export 'elemento_seleccionable.dart';
export 'enlace.dart';
export 'formato.dart';
export 'lista_seleccionables.dart';
export 'perfil.dart';
\ No newline at end of file
export 'perfil.dart';
export 'conversor.dart';
\ No newline at end of file
import 'dart:io';
import 'package:ffmpeg_kit_flutter/return_code.dart';
import 'package:flutter/material.dart';
import 'package:file_picker/file_picker.dart';
import 'package:provider/provider.dart';
......@@ -55,11 +56,20 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
);
}
List<Widget> _loadConvertirActionButtons (BuildContext context) {
List<Widget> _loadConvertirActionButtons (BuildContext context,
ListaSeleccionables manager)
{
final buttons = <Widget>[
ActionButton(
tipoBoton: ActionButtonTypes.copiar,
onPressed: () {},
onPressed: () {
List<Archivo> archivos = manager.seleccionables.whereType<Archivo>().toList();
var results = <Future<ReturnCode?>>[];
for (var archivo in archivos) {
results.add(Conversor.convertir(archivo));
}
}
),
ActionButton(
tipoBoton: ActionButtonTypes.reemplazar,
......@@ -86,7 +96,7 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
icon: Icon(Icons.label_important_outline),
label: 'Convertir',
key: _convertirKey,
children: _loadConvertirActionButtons(context)
children: _loadConvertirActionButtons(context, manager)
),
SizedBox(
width: 130,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment