Description
The UploadVideo
method is a static extension method provided by the SandboxToolExtensions
class. It allows you to upload a video file to a specified asset in the Sandbox environment. This method is asynchronous and returns a Task<bool>
indicating the success or failure of the upload operation.
Usage
To use the UploadVideo
method, you need to provide the following parameters:
asset
: An instance of Editor.Asset
representing the asset to which the video will be uploaded.
contents
: A byte array (byte[]
) containing the video data to be uploaded.
isThumbVideo
: A boolean value indicating whether the video is a thumbnail video.
hidden
: A boolean value indicating whether the video should be hidden after upload.
tag
: A string representing a tag to associate with the video.
progress
: A callback of type Sandbox.Utility.DataProgress.Callback
to report the progress of the upload.
token
: A CancellationToken
to observe while waiting for the task to complete.
Example usage:
var asset = new Editor.Asset();
byte[] videoData = File.ReadAllBytes("path/to/video.mp4");
bool isThumbnail = false;
bool shouldHide = false;
string videoTag = "exampleTag";
var progressCallback = new Sandbox.Utility.DataProgress.Callback((progress) => {
// Handle progress update
});
var cancellationToken = new CancellationToken();
bool success = await SandboxToolExtensions.UploadVideo(asset, videoData, isThumbnail, shouldHide, videoTag, progressCallback, cancellationToken);
if (success)
{
// Video uploaded successfully
}
else
{
// Handle upload failure
}
Example
var asset = new Editor.Asset();
byte[] videoData = File.ReadAllBytes("path/to/video.mp4");
bool isThumbnail = false;
bool shouldHide = false;
string videoTag = "exampleTag";
var progressCallback = new Sandbox.Utility.DataProgress.Callback((progress) => {
// Handle progress update
});
var cancellationToken = new CancellationToken();
bool success = await SandboxToolExtensions.UploadVideo(asset, videoData, isThumbnail, shouldHide, videoTag, progressCallback, cancellationToken);
if (success)
{
// Video uploaded successfully
}
else
{
// Handle upload failure
}