ve_sdk_flutter 0.0.1 copy "ve_sdk_flutter: ^0.0.1" to clipboard
ve_sdk_flutter: ^0.0.1 copied to clipboard

Banuba Video Editor Flutter plugin.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:ve_sdk_flutter/export_result.dart';
import 'package:ve_sdk_flutter/ve_sdk_flutter.dart';

const _licenseToken = 'Qk5CIGyacGpKGELe2t0UwjP/tbIHIVKnoC2EJZ9pzP3PiPDBX+pxfKnOVy+sICWEvPQxnuzMIPopynNbD4osLahBC7ns3UtK0suaZAiuhq2fBBzhsRHJmo4s2B1GNRg7lL3jJFaL7zj8v+IlR9cOY1JmY0kl20bmrDn/jqif7rUl58BTRF3+q7A9oIFkOAT2AfnwrX9xN2DjLCNysMU4kJjlHa4Cm68oPAMdDxC1OcTGUxy9hCEaGnqqLIAfp2wuU1SE/eiFQqqdjX720YvLJGmhcUcDN3cBJcP60TIILsFsRS9r4UHe3NPhfYP46NOWTb2JDuCaqWIAbkeGrz3LVQs10oG6/XzMuS3pdmMFq71D37jZvaFAvoKh5O0RkQ6Tv+TYRaWSolQ6FXVxeKeZSXwOHPvtCG5akbE6nzaOFswXDRsasg8QTWbzmeBaQVMtXaZeZA1f9QVS81io/NEpPGZBt/hhX3+rDbbySICpZws+F+JNVCOSU/6QftHbARzJg5lcyl2HGQlDzi6asN/r6jM2QbUn1lISijyaAgC36nfmCPJH/Uz9EDP7D2J+AM8VBsHfpfT72yUZ0qVeCNEPX6TI8EwR2s0N2QwY6uJs5r7lsojXDUOUprWazNEVIq9B1gDW/OWy5HlGkmu3TjjWdEhIrZyGSHAW9pUNfov4BiD5diOSd99HiHIxLx2T0IbylsN6J3I2kUKCglX7JV01W72AO+ynl9IU04fxxsmSwuX4vvdMCMnyE2xx2OF/Uy0+vEubut0bZR5cmS12CCE5JtLnbJ8h7OlJy96FoFLxtxKkqNFx3AoCBMB0KughJnFcIcytsNRX81AdvE6bhkYRV3yKTbTcDhORg7/g/wpoO3AQUQpN/pfFOztCtQealfcjVUdUJaWpOXjDTV3huVC76wtCbQL2Q465E6NDn3Ksye69JYE3pqvywKqvmRMYVwfuJIbTi/MqAccbMdkFrnuet+74cff7cfwB5fuSujzTDKMJTL7qHEfMD6Sgl17VyleXGlcq/4sTebD3J1k2rzWE+LcDgG3gQvFXq448MyWG1GAqmKAbbqvZPmTJx050BVmbznjFPD+LbVKTHh3RWIyiB+uDN+ptQd3eTbh5CzHEdtMLSq+/PhjXwT6FNTDd7hmR3SGW7c/TBnPWE5kA0uhMWq98L27/n3ApLENYJiEl3PJ8zS34jZ4ZhK/p0YFYpn1CD+408EYCShtXGuz1UANYqCHJ2g98QG3AaFSYE9YvrK6pWaGXgnhi3BvyX2Te84XXOMcFLLo=';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final _veSdkFlutterPlugin = VeSdkFlutter();
  String _errorMessage = '';

  Future<void> _startVideoEditorInCameraMode() async {
    try {
      dynamic exportResult = await _veSdkFlutterPlugin.openCameraScreen(_licenseToken);
      _handleExportResult(exportResult);
    } on PlatformException catch (e) {
      _handlePlatformException(e);
    }
  }

  Future<void> _startVideoEditorInPipMode() async {
    final ImagePicker picker = ImagePicker();
    final videoFile = await picker.pickVideo(source: ImageSource.gallery);

    final sourceVideoFile = videoFile?.path;
    if (sourceVideoFile == null) {
      debugPrint('Error: Cannot start video editor in pip mode: please pick video file');
      return;
    }

    try {
      dynamic exportResult = await _veSdkFlutterPlugin.openPipScreen(_licenseToken, sourceVideoFile);
      _handleExportResult(exportResult);
    } on PlatformException catch (e) {
      _handlePlatformException(e);
    }
  }

  Future<void> _startVideoEditorInTrimmerMode() async {
    final ImagePicker picker = ImagePicker();
    final videoFiles = await picker.pickMultipleMedia(imageQuality: 3);

    if (videoFiles.isEmpty) {
      debugPrint('Error: Cannot start video editor in trimmer mode: please pick video files');
      return;
    }

    final sources = videoFiles.map((f) => f.path).toList();

    try {
      dynamic exportResult = await _veSdkFlutterPlugin.openTrimmerScreen(_licenseToken, sources);
      _handleExportResult(exportResult);
    } on PlatformException catch (e) {
      _handlePlatformException(e);
    }
  }

  void _handleExportResult(ExportResult? result) {
    if (result == null) {
      debugPrint('No export result! The user has closed video editor before export');
      return;
    }

    // The list of exported video file paths
    debugPrint('Exported video files = ${result.videoSources}');

    // Preview as a image file taken by the user. Null - when preview screen is disabled.
    debugPrint('Exported preview file = ${result.previewFilePath}');

    // Meta file where you can find short data used in exported video
    debugPrint('Exported meta file = ${result.metaFilePath}');
  }

  void _handlePlatformException(PlatformException exception) {
    _errorMessage = exception.message ?? 'unknown error';
    // You can find error codes 'package:ve_sdk_flutter/errors.dart';
    debugPrint("Error: code = ${exception.code}, message = $_errorMessage");

    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Banuba Video Editor Flutter plugin"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Padding(
              padding: EdgeInsets.all(15.0),
              child: Text(
                'The plugin demonstrates how to use Banuba Video Editor',
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 17.0,
                ),
              ),
            ),
            Visibility(
              visible: _errorMessage.isNotEmpty,
              child: Padding(
                padding: const EdgeInsets.all(15.0),
                child: Text(
                  _errorMessage,
                  textAlign: TextAlign.center,
                  style: const TextStyle(fontSize: 17.0, color: Colors.red),
                ),
              ),
            ),
            const SizedBox(height: 24),
            MaterialButton(
              color: Colors.blue,
              textColor: Colors.white,
              disabledColor: Colors.grey,
              disabledTextColor: Colors.black,
              padding: const EdgeInsets.all(12.0),
              splashColor: Colors.blueAccent,
              minWidth: 240,
              onPressed: () => _startVideoEditorInCameraMode(),
              child: const Text(
                'Open Video Editor - Camera screen',
                style: TextStyle(
                  fontSize: 14.0,
                ),
              ),
            ),
            const SizedBox(height: 24),
            MaterialButton(
              color: Colors.blue,
              textColor: Colors.white,
              disabledColor: Colors.grey,
              disabledTextColor: Colors.black,
              padding: const EdgeInsets.all(12.0),
              splashColor: Colors.blueAccent,
              minWidth: 240,
              onPressed: () => _startVideoEditorInPipMode(),
              child: const Text(
                'Open Video Editor - PIP screen ',
                style: TextStyle(
                  fontSize: 14.0,
                ),
              ),
            ),
            const SizedBox(height: 24),
            MaterialButton(
              color: Colors.blue,
              textColor: Colors.white,
              disabledColor: Colors.grey,
              disabledTextColor: Colors.black,
              padding: const EdgeInsets.all(12.0),
              splashColor: Colors.blueAccent,
              minWidth: 240,
              onPressed: () => _startVideoEditorInTrimmerMode(),
              child: const Text(
                'Open Video Editor - Trimmer screen',
                style: TextStyle(
                  fontSize: 14.0,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
0
pub points
73%
popularity

Publisher

unverified uploader

Banuba Video Editor Flutter plugin.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on ve_sdk_flutter