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

Banuba Video Editor Flutter plugin.

example/lib/main.dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:ve_sdk_flutter/export_data.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/features_config.dart';
import 'package:ve_sdk_flutter/ve_sdk_flutter.dart';

const _licenseToken = "Qk5CIJU7P3hWzaJU7Agj3HXurr3uxMfvSfaURjVFh1dKhvmwHKRE9zX9oxi1v7m6PYLoz255OhlCTQ5bJXOi/eRHdsxEQBYC0y+29ZE8hXjnG3EupbeAkckEH7NG9bG8Szoxb4kzfxPkBBlG+3ljavrQE3i2bjmRbdWeQPnLt6K/l16YULIXFj3T0vM9XgmJ34zddy3LM9N5dfiZJUR5Kv17loj7Cgcorj2xfXHCGzKTRprHqd4CaOC0RDob4op/r5/BqqdgKxNwEz9p9/2yKmSKliGQN9/hZB13szYwRVKWq73MUIXR+Fj6FT3vgmLZ+cQhFoeO1U3St2d/PLerLATmIkH7PViwkliKr/ccG0dYDVUr4zg7EBfjlCTZUjH7ZOrdrHGlmNPNFmdLVG40pr8do2wVQK7KXq/+x8z28PtGKsupTUFAA0WL4Sx7IWWZ4FTwwJuoLFoZu74XgjOSnyl41fJAS83jp75LkwD0MJcI3dtfmzAWNHr1+DxndOJ9NU5NG5KuWVd9DwB8pc3APMaFcf++vBzlXKXttxIi4nuqfsCVxH2ZuiCX0Ek9zmgpajdRGb/tFJ8VSh0wVQlWBqW83WQp/zrMvva5Ej5ddedXEPY/WjcURYFnSj2oKgZsdafBVXlp5rSmjlQWQQY6gYICwtDmVo029rBxLS20N+ysdKbtErmXe3SLt5Ce+czXiCPzUUu+jkSQaM0PwitEXzXed2WSkr1DjKkv7hml7EGrKCCdim0JYPCMAuDC6q00b/CP7/fvqGCUw/r+qFPwokBtSAkoZzmWmwc/nC6uhlXo6+Ne7ifm/IEAkw1elAEJnJgEh3bkhyomIk4qFj+EL43CfgPzySHbBfy1il41x8t/9DdCd4OhUmSpt1V6Q2XJIL2uyiUWxVFCF3hQvpGk1+gwEQONj321qLeA4XxN+nD87M1029dR2XwfwYrppV17NUA7OFDzXcvtdhCvGGWn4smzsiQ5qpwjIhFg8xRZgjiwfTBtIz8WJTSZ821xKCy6N2rVu4+wFJaqsSRl7HtsN3SpmVoMAoDOiF6PDP8V/zihs/lK06BJTJhXnllGIYhkw7donsN+kkqzP2wC7kb1Gf01JUhqPEjXAv52yPqc3/KV2AymZU83DS+UEN9d2cXJeH/xDwtxqnl8hR5id4yq9bhmH6LadJxecanFhJ3qCPZ3vAZBiilpeRwcc3T2PLRiyqZOXCn7f1lOekWnfNRvSQCg5uqsZRHZOBwEowOnkyUOU8wrhEyEzj7SjIh2hl05DmAcy3TLMo3baKeu0LUSFnGcd6Fw+reZuTAE6M7IuVpPVnZ9crlb2F7C7v3PTp1RIvUq+9TkK/+E/EEXwaSZXj37PpyOFBuT3dqHy6suoUoeTiTT5lnqpWTsMi22yVmD/6FpuQpMyyl5edo3qwPBWFXFt+QcHIkEug7eWEjD3TLaLdhdcOG77IjQBR5LTZB+eUhBj5KAX9zHsjGMEzWYZQG56hpNgMmO+bj8K9lKaaK5PxuXUnooZcq4e4DHKymZVhS4IkJFGfUtDqwblS2k6awY0go0q0kBLN2eEFrTOW9nANzW9WfJiVbdSSj2AllqV8JvgV2tL1ravdgIvocXwN+M/ixbP4NoSEnuNVO0xbiYRiBdribLu3dabi6T0Vtt3CEIQ3j34ElkCvP27G6IQecs9RQ5df1UF0qWP43V08cwMIQF4IJXPKx0OJiB9QimW2AGnXoT9Z9iwshf8j6/aWWscm7IjZAk7RKO94JfYLdXbxmbf+Biz5tEHw2loyR3vllbUQ==";

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 {
    // Specify your Config params in the builder below

    final config = FeaturesConfigBuilder()
        // .setCaptions(...)
        // ...
        .build();

    // Export data example

    // const exportData = ExportData(exportedVideos: [
    //   ExportedVideo(
    //       fileName: "export_HD",
    //       videoResolution: VideoResolution.hd720p
    //   )],
    //     watermark: Watermark(
    //        imagePath: "assets/watermark.png",
    //        alignment: WatermarkAlignment.topLeft
    //     )
    // );

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

  Future<void> _startVideoEditorInPipMode() async {

    // Specify your Config params in the builder below

    final config = FeaturesConfigBuilder()
      // .setAudioBrowser(...)
      // ...
      .build();
    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, config, sourceVideoFile);
      _handleExportResult(exportResult);
    } on PlatformException catch (e) {
      _handlePlatformException(e);
    }
  }

  Future<void> _startVideoEditorInTrimmerMode() async {

    // Specify your Config params in the builder below

    final config = FeaturesConfigBuilder()
      // .setDraftConfig(...)
      //...
      .build();
    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, config, 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(
        backgroundColor: Colors.black38,
        centerTitle: true,
        title: const Text("Video Editor Flutter plugin"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Expanded(
              flex: 1,
              child: Center(
                child: 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,
                    ),
                  ),
                ),
              ),
            ),
            Expanded(
              flex: 2,
              child: Column(
                children: [
                  Visibility(
                    visible: _errorMessage.isNotEmpty,
                    child: Text(
                      _errorMessage,
                      textAlign: TextAlign.center,
                      style: const TextStyle(fontSize: 17.0, color: Colors.red),
                    ),
                  ),
                  const SizedBox(height: 20),
                  ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      foregroundColor: Colors.white,
                      backgroundColor: Colors.blueAccent,
                      shadowColor: Colors.blueGrey,
                      elevation: 10,
                      fixedSize: const Size(300, 50),
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(30),
                      ),
                    ),
                    onPressed: () => _startVideoEditorInCameraMode(),
                    child: const Text(
                      'Open Video Editor - Camera screen',
                      style: TextStyle(
                        fontSize: 14.0,
                      ),
                    ),
                  ),
                  const SizedBox(height: 20),
                  ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      foregroundColor: Colors.white,
                      backgroundColor: Colors.blueAccent,
                      shadowColor: Colors.blueGrey,
                      elevation: 10,
                      fixedSize: const Size(300, 50),
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(30),
                      ),
                    ),
                    onPressed: () => _startVideoEditorInPipMode(),
                    child: const Text(
                      'Open Video Editor - PIP screen ',
                      style: TextStyle(
                        fontSize: 14.0,
                      ),
                    ),
                  ),
                  const SizedBox(height: 20),
                  ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      foregroundColor: Colors.white,
                      backgroundColor: Colors.blueAccent,
                      shadowColor: Colors.blueGrey,
                      elevation: 10,
                      fixedSize: const Size(300, 50),
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(30),
                      ),
                    ),
                    onPressed: () => _startVideoEditorInTrimmerMode(),
                    child: const Text(
                      'Open Video Editor - Trimmer screen',
                      style: TextStyle(
                        fontSize: 14.0,
                      ),
                    ),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
4
likes
0
points
760
downloads

Publisher

unverified uploader

Weekly Downloads

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

Packages that implement ve_sdk_flutter