truvideo_media_sdk 1.0.3 copy "truvideo_media_sdk: ^1.0.3" to clipboard
truvideo_media_sdk: ^1.0.3 copied to clipboard

Manages cloud-based media operations, including uploading photos/videos and generating links, with support for canceling uploads.

Truvideo Media SDK #

This Flutter plugin integrates the TruvideoMediaSdk for uploading media files (videos, images, etc.) with rich metadata and tags. It also allows retrieving upload progress and searching media based on tags.

Supported Platforms #

  • Android
  • iOS

Features #

  • Upload media files (e.g., videos) with tags and metadata
  • Track upload progress, success, and errors with callbacks
  • Search media based on uploaded tags
  • Retrieve upload metadata by ID or fetch all uploads

Requirements #

  • TruvideoMediaSdk Plugin

Setup #

  1. Add TruvideoMediaSdk Plugin to your project.
  2. Install dependencies:
    flutter pub get
    
  3. Ensure proper permissions in AndroidManifest.xml & Info.plist.
  4. Run the app:
    flutter run
    

Usage #

Upload Request:

  • Create new upload request with a file path.
  • Set tags and metadata for the upload (optional).
  • Build the request and start the upload.
  • Track upload progress, success, and errors with callbacks.
Future<void> createUploadRequest(String filePath) async {
  try {
    // Create a new MediaBuilder with a test file path
    final builder = MediaBuilder(filePath)
      ..setTag("color", "blue")
      ..setTag("source", "flutter-sdk")
      ..setMetaData("uploadedBy", "truvideo");

    // Build the media upload request
    await builder.build();

    final mediaId = builder.getMediaId();
    print("Upload media ID is: $mediaId");

    // Start the upload with event callbacks
    await builder.upload(
      onProgress: (e) => print("Upload Progess: ${e['progress']}%"),
      onComplete: (e) => print("Upload Complete: ${e['remoteURL']}"),
      onError: (e) => print("Upload Failed: ${e['error']}"),
    );
  } catch (e) {
    debugPrint('Upload flow failed: $e');
  }
}

Get request by ID

  • Use getFileUploadRequestById function to fetch request associated with the id. The function will return MediaBuilder? object.
void getRequestById(String id) async {
  try {
    MediaBuilder? requests =  await TruvideoMediaSdk.getFileUploadRequestById(id);

    if (requests != null) {
      print(request.mediaDetail?.id);
    }
  } on PlatformException catch (e) {
    print('Error while fetching upload request: ${e.message}');
  }
}

Get all requests

  • Use getAllFileUploadRequests function to fetch all the file upload request. The function will return List
void getAllUploadRequest() async {
  try {
    List<MediaBuilder>? result = await TruvideoMediaSdk.getAllFileUploadRequests();

    if (result != null) {
      for(var request in result){
          print(request.mediaDetail?.id);
      }
    }
  } on PlatformException catch (e) {
    print('Error while fetching upload requests: ${e.message}');
  }
}

Search Media

  • Search/fetch uploaded Media
  Future<void> searchMedia() async {
  try {
    Map<String, String> tags = {"color": "blue", "source": "flutter-sdk"};

    final response = await mediaSdkWrapper.search(
      tagJson: jsonEncode(tags),
      type: 'all', // 'all', 'video', 'image'
      page: 1,
      pageSize: 10,
      addedToLibrary: true,
    );

    if (response != null && response.data != null) {
      print(response.data.toString());
    }
  } on PlatformException catch (e) {
    print('Error on search media: ${e.message}');
  }
}

License #

MIT #

Support #

If you have any questions or suggestions regarding the SDK, please contact us at [email protected].

1
likes
80
points
268
downloads

Publisher

verified publishertruvideo.com

Weekly Downloads

Manages cloud-based media operations, including uploading photos/videos and generating links, with support for canceling uploads.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on truvideo_media_sdk

Packages that implement truvideo_media_sdk