No description or website provided.
Java
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
samples
sources
ChangeLog
README.md

README.md

vzaar API Java client

Lighter and faster vzaar API client for Java developers. Documentation provided below is valid for the library version 2.0 and above.


vzaar is the go to video hosting platform for business. Affordable, customizable and secure. Leverage the power of online video and enable commerce with vzaar.


Using the library

To start, make sure you have included vzaar-java-api.jar into your Project References.

import com.vzaar.Vzaar;

Now you can create your vzaar client instance:

Vzaar api = new Vzaar("VZAAR_USERNAME", "VZAAR_TOKEN");

In order to use vzaar API, you need to have a valid user name and API token that you can get from your vzaar dashboard at http://app.vzaar.com/settings/api.

The very next thing you would want to do is to check if your account actually works and operational and you can do it by simple calling whoAmI():

    Vzaar api = new Vzaar(args[0], args[1]);
    String whoAmI = api.whoAmI();
    if (whoAmI.length() != 0) 
    {
      System.out.println("WhoAmI - " + whoAmI + "\n");
    }
    else
    {
      System.out.println("Error\n");
    }

If it returns you your vzaar username, - we are good to go.

User Details

This API call returns the user's public details along with it's relevant metadata. It also contains vzaar Account ID that you can use in api.getAccountDetails call.

UserDetails details = api.getUserDetails(VZAAR_USERNAME);

Where VZAAR_USERNAME is the vzaar username. Result of this call will be an object of UserDetails type.

Account Details

This API call returns the details and rights for each vzaar subscription account type along with it's relevant metadata. This will show the details of the packages available here: http://vzaar.com/pricing

AccountDetails details = api.getAccountDetails(VZAAR_ACCOUNT_ID);

Where VZAAR_ACCOUNT_ID is the unique account id assigned by vzaar.

Result of this call will be an object of AccountDetails type.

Video List

This API call returns a list of the user's active videos along with it's relevant metadata. 20 videos are returned by default but this is customizable.

VideoListQuery query = new VideoListQuery;
query.count = 10;
query.page = 1;
List<Video> list = api.getVideoList(query);

Video Details

This API call returns metadata about selected video, like its dimensions, thumbnail information, author, duration, play count and so on.

api.getVideoDetails(VZAAR_VIDEO_ID);

Where VZAAR_VIDEO_ID is unique vzaar video ID assigned to a video after its processing.

Upload Signature

In some cases you might need to not perform actual uploading from API but to use some third-party uploaders, like S3_Upload widget, or any other, so you would need to get only upload signature for it, so now you can have it as UploadSignature object, as XML string, as XmlDocument or as JSON string.

UploadSignature signature = null;
UploadSignatureQuery query = new UploadSignatureQuery();

query.path =  URLEncoder.encode("/path/to/file/video.mp4", "UTF-8");
query.filename = URLEncoder.encode("video.mp4", "UTF-8");
query.fileSize = 465756543;
query.multipart = true;

signature = api.getUploadSignature(query);

System.out.println("Upload Signature - " + signature.toString());

UploadSignatureQuery has the following parameters:

  • redirectUrl - post upload redirection URL
  • multipart - true|false, enables or disables multipart upload support
  • path - local path of the video file to be uploaded
  • url - remote path of the video file to be uploaded
  • filename - basename of file being uploaded
  • filesize - size in bytes of file being uploaded

In UploadSignatureQuery path or url are parameters mandatory, if either of them used it will throw an error. url parameter used to upload from URL and path to upload from the local storage.

Both filesize and filename are mandatory in order to initiate the c orrect S3 multipart upload, although no exception will be raised from the API if either is missing. In the case of either of these parameters being missing, no errors will be raised but video processing will be significantly slower, especially for large files.

Uploading video

Upload video from local drive directly to Amazon S3 bucket. Use this method when you build desktop apps or when you upload videos to vzaar directly from your server.

String guid = api.uploadVideo("PATH/TO/SOME_FILE");

Keep in mind that file uploaded to a Amazon S3 storage in chunks of 128Kb, you can adjust this chunk size this way:

api.bufferSize = 262144; //256 kb

Processing video

This API call tells the vzaar system to process a newly uploaded video. This will encode it if necessary and then provide a vzaar video ID back.

VideoProcessQuery processQuery = new VideoProcessQuery();
processQuery.guid = "vzcf7af7bc5a734c30a46ca3911e7f3458";
processQuery.title = "My awesome video";
processQuery.description = "The story about how easy to build awesome apps with vzaar API";
processQuery.profile = VideoProfile.ORIGINAL;
processQuery.labels = new String[]{"api", "tutorials"};

int x = api.processVideo(processQuery);

If you want to replace existing video with some newly uploaded, you can call Process Video with adding replaceId parameter equal to vzaar video ID of the video that needs to be replaced.

VideoProcessQuery processQuery = new VideoProcessQuery();
processQuery.guid = "vzcf7af7bc5a734c30a46ca3911e7f3458";
processQuery.replaceId = 12345678; //vzaar Video ID of the video you want to replace
processQuery.title = "My awesome video";
processQuery.description = "The story about how easy to build awesome apps with vzaar API";
processQuery.profile = VideoProfile.ORIGINAL;
processQuery.labels = new String[]{"api", "tutorials"};

int x = api.processVideo(processQuery);

Editing video

This API call allows a user to edit or change details about a video in the system.

VideoEditQuery editQuery = new VideoEditQuery();
editQuery.title = "My REALLY awesome video";
editQuery.description = "The story about how easy to build awesome apps with vzaar API";
editQuery.markAsPrivate = true;

Boolean x = api.editVideo(editQuery);

Notice markAsPrivate property in VideoEditQuery variable, you can pass there true or false, and this property marks the video as private (if true) or public (if false).

Deleting video

This API call allows you to delete a video from your account. If deletion was successful it will return you true otherwise false.

Boolean result = api.deleteVideo(VZAAR_VIDEO_ID);

Where VZAAR_VIDEO_ID is unique vzaar video ID assigned to a video after its processing.

License

Released under the MIT License.