Capture Media

This documentation provides guidelines on capturing images and recording videos using the TruVideo Camera SDK. The SDK offers simple methods to integrate camera functionalities into your application.

Prerequisites

  • Ensure you have integrated the TruVideo Core SDK into your project and completed with the authentication process

Capturing an Image

To capture an image, follow these steps:

Step 1 : Create Async Callback Wrapper

#if ANDROID
private Task<T> ExecuteCameraCallbackAsync<T>(Action<CameraCallback> action)
{
    var tcs = new TaskCompletionSource<T>();

    action.Invoke(new CameraCallback(
        success => MainThread.BeginInvokeOnMainThread(() =>
            tcs.TrySetResult((T)Convert.ChangeType(success, typeof(T)))),
        failure => MainThread.BeginInvokeOnMainThread(() => tcs.TrySetException(new Exception(failure)))
    ));

    return tcs.Task;
}
#endif

#if IOS
private Task<T> ExecuteCallbackAsync<T>(Action<Action<string, NSError>> nativeCall) {
    var tcs = new TaskCompletionSource<T>();
    nativeCall((nsResult, error) => {
        if (error != null)
        {
            tcs.SetException(new Exception(error.LocalizedDescription));
        }
        else {
            // Convert NSString to string
            string result = nsResult.ToString();
            tcs.TrySetResult((T)Convert.ChangeType(result, typeof(T)));
           // tcs.SetResult(result);
        }
    });
    return tcs.Task;
}
#endif

Step 2 : Create new configuration to give to the camera

Step 3 : Present the camera with the configuration

Finalize :

After completing this steps the function should look like

What’s Next?

Now that you can capture media, you’re ready to:


By following this guide, you’ve enabled rich media capture in your iOS app with just a few lines of code. Let’s keep going!

Last updated

Was this helpful?