Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

22 Commits

Repository files navigation

JW Platform API Client

The JWPlatform library provides convenient access to the JW Platform Management API from applications written in the Java language.

Visit JW Player Developer site for more information about JW Platform API.

Requirements

Java 8 and later.

Install With Maven:

Add this dependency to your project's POM:

<dependency>
<groupId>com.jwplayer</groupId>
<artifactId>jwplatform</artifactId>
<version>1.1.0</version>
</dependency>

V2 Client

Usage

The following is an example of how to use the V2 client, MediaClient, used to access all media v2 api routes:

importjava.util.HashMap;
importjava.util.Map;
importorg.json.JSONArray;
importorg.json.JSONObject;
importcom.jwplayer.jwplatform.client.MediaClient;
importcom.jwplayer.jwplatform.exception.JWPlatformException;
publicclassExample {
publicstaticvoidmain(String[] args) {
StringapiSecret = "secret";
try {
MediaClientclient = MediaClient.getClient(apiSecret);
// Query paramsMap<String, String> params = newHashMap<>();
params.put("page_length", "10");
JSONObjectlistMediaResponse = client.listAllMedia("yourSiteId", params);
System.out.println(listMediaResponse);
// Show the list of media for the site IdJSONArraymedia = (JSONArray) listMediaResponse.getJSONArray("media");
System.out.println(media);
} catch (JWPlatformExceptione) {
e.printStackTrace();
}
}
}

V1 Client

The V1 Client remains available for use, but is deprecated. We strongly recommend using the V2 Client.

Usage

The following is an example of how to use the V1 client for a video of sourcetype url:

importcom.jwplayer.jwplatform.v1.JWPlatformClient;
importcom.jwplayer.jwplatform.exception.JWPlatformException;
importjava.util.HashMap;
importjava.util.Map;
importorg.json.JSONObject;
publicclassJWPlatformClientExample {
publicstaticvoidmain(String[] args) {
StringapiKey = "key";
StringapiSecret = "secret";
StringvideosCreatePath = "videos/create";
Map<String, String> videosCreateParams = newHashMap<>();
videosCreateParams.put("sourcetype", "url");
videosCreateParams.put("sourceformat", "mp4");
videosCreateParams.put("sourceurl", "http://www.some-url.com/some-video.mp4");
videosCreateParams.put("title", "Some Video Title");
StringvideosShowPath = "/videos/show";
try { JWPlatformClientclient = JWPlatformClient.create(apiKey, apiSecret);
// Create a video assetJSONObjectvideosCreateResponse = client.request(videosCreatePath, videosCreateParams);
System.out.println(videosCreateResponse);
// Show the properties of the created videoStringvideoKey = videosCreateResponse.getJSONObject("video").getString("key");
Map<String, String> videosShowParams = newHashMap<>();
videosShowParams.put("video_key", videoKey);
JSONObjectvideosShowResponse = client.request(videosShowPath, videosShowParams);
System.out.println(videosShowResponse);
} catch (JWPlatformExceptione) {
e.printStackTrace();
}
}
}

The following is an example of how to use the client for a video of sourcetype file:

importcom.jwplayer.jwplatform.JWPlatformClient;
importcom.jwplayer.jwplatform.exception.JWPlatformException;
importjava.util.HashMap;
importjava.util.Map;
importorg.json.JSONObject;
publicclassJWPlatformClientExample {
publicstaticvoidmain(String[] args) {
StringapiKey = "key";
StringapiSecret = "secret";
StringvideosCreatePath = "/videos/create";
Map<String, String> videosCreateParams = newHashMap<>();
videosCreateParams.put("sourcetype", "file");
videosCreateParams.put("title", "Some Video Title");
StringlocalFilePath = "/some/path/test_video.mp4";
try {
JWPlatformClientclient = JWPlatformClient.create(apiKey, apiSecret);
// Create a video assetJSONObjectvideosCreateResponse = client.request(videosCreatePath, videosCreateParams);
System.out.println(videosCreateResponse);
// Upload the video from local file systemJSONObjectvideoUploadResponse = client.upload(videosCreateResponse, localFilePath);
System.out.println(videoUploadResponse);
} catch (JWPlatformExceptione) {
e.printStackTrace();
}
}

Note

In the preceding V1 example snippets, all URL paths feature a leading slash. These must be included for the URL builder to work properly.

Supported operations

All API methods documented in our api documentation are available in this client. Please refer to our api documentation.

ChangeLog

See the Change Log for recent changes.

License

JW Platform API library is distributed under the Apache 2 license.

About

☕ Java client for the JW Platform API

Topics

Resources

Code of conduct

Stars

8 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages