api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes.
DEPRECATION WARNING: this SDK will soon be deprecated and will no longer be maintained. It has been replaced by the Java API client. Please use it instead.
This SDK provides a Java client for api.video service. This is an early version, feel free to report any issue.
- Download the latest release.
- Add the following dependencies in your
build.gradle
file:
// build.gradle
dependencies {
implementation 'com.konghq:unirest-java:3.11.03'
implementation files('libs/java-sdk-0.6.5.jar')
}
import java.io.File;
import video.api.java.sdk.Client;
import video.api.java.sdk.ClientFactory;
import video.api.java.sdk.domain.exception.ResponseException;
import video.api.java.sdk.domain.video.Video;
public class Main {
public static void main(String[] args) throws ResponseException {
Client client = new ClientFactory().create("YourProductionApiKey");
// Client client = new ClientFactory().createSandbox("YourSandboxApiKey");
// Upload a new video
Video video = client.videos.upload(new File("/path/to/file.mp4"));
// Get its embed code
String embedCode = video.assets.get("iframe"); // <iframe src="..."></iframe>
}
}
// Upload a video with properties
VideoInput videoInput = new VideoInput();
videoInput.title = "My title";
videoInput.tags.add("my tag");
videoInput = client.videos.upload(new File("/path/to/file.mp4"), videoInput);
// Iterate over videos (paging is handled by the client)
for (Video v : client.videos.list()) {
String videoTitle = v.title;
}
Most of api.video features are implemented and autocompleted within your favorite IDE:
client.videos; // https://docs.api.video/5.1/videos
client.players; // https://docs.api.video/5.1/players
client.captions; // https://docs.api.video/5.1/captions
client.liveStreams; // https://docs.api.video/5.1/live
client.chapters(videoId); // https://docs.api.video/5.1/chapters
// https://docs.api.video/5.1/analytics
client.liveStreamAnalytics;
client.sessionEventAnalytics;
client.videoAnalytics;