This document describes the Video Cloud App SDK for Android, which enables you to develop your own Android native application to deliver your Video Cloud videos to Android device platforms. In addition to this getting started article, check out these documents:
The Video Cloud App SDK for Android is a Java Library for employing the Video Cloud Media API and for playing videos in a custom Video Cloud movie player on Android devices. The Media API provides a Java interface for the Video Cloud video and playlist APIs.
With the expansion of the Android Marketplace and the Android platform, the demand for mobile media continues to grow. Using this SDK to create a native Android application will help you to create a unique experience for viewers. You can easily access and retrieve your video content and metadata using the SDK so you can tailor your app for viewers on the go and keep your brand visible and close to your audience at all times.
Note that the Video Cloud App SDK for Android supports video on demand, but does not support live streaming video.
If you are considering building an Android application, its never too early to start preparing your video content for mobile delivery. Read more about encoding video for mobile delivery.
This release of the Video Cloud App SDK for Android requires that you have Android SDK version 1.5 or higher.
Before testing your project make sure that you have added the android.permission.INTERNET permission in your AndroidManifest.xml. If not, you will most likely just see a black screen.
To install the Video Cloud App SDK for Android:
The MediaAPI class is a façade for all Video Cloud Media API class. This enables developers to instantiate it once for any needed calls:
Logger APILogger = Logger.getLogger("BCAndroidAPILogger");
ReadAPI readAPI = new ReadAPI("MyApiToken");
readAPI.setLogger(APILogger);
Invoke a BC Media API method that returns a BCVideo, BCPlaylist, or BCItemCollection. The setLogger() function is not optimal for released builds of your app but can be handy when debugging during development.
import com.brightcove.mobile.mediaapi.ReadAPI;
public static final String MY_READ_TOKEN YOUR READ TOKEN;
Logger APILogger = Logger.getLogger("BCAndroidAPILogger");
ReadAPI readAPI = new ReadAPI(MY_READ_TOKEN);
readAPI.setLogger(APILogger);
//will return video in the user's account with ID:1234
EnumSet<VideoFieldEnum> videoFields = VideoFieldEnum.createEmptyEnumSet();
videoFields.add(VideoFieldEnum.ID);
videoFields.add(VideoFieldEnum.NAME);
videoFields.add(VideoFieldEnum.RENDITIONS);
videoFields.add(VideoFieldEnum.FLVURL);
try{
Video video = readAPI.findVideoById(1234, videoFields, null);
} catch(Exception e){
String msg = e.getMessage();
}
The BCPlayerView class is the public component which allows you to play and stop videos:
BCPlayerView player; player = (BCPlayerView) findViewById(R.id.player); player.load(pVideo); //video fetched via the media apis, type is Video player.start();
Developers will also need to embed the BCPlayerView in a layout using XML, as in this example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<com.brightcove.mobile.android.BCPlayerView
android:id="@+id/player"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
</com.brightcove.mobile.android.BCPlayerView>
</LinearLayout>
The controls in the Video Cloud Player SDK are implemented using a combination of layout XML to arrange the components, and Java code in the View to handle event callbacks and manage view state. The player controls use custom layout, so Android's MediaController class is not used. To make use of the player controls in your project, find the res/ folder in the Video Cloud Player SDK and copy all those files into your project's res/ folder.
If you need help or have a question, please visit our forums. You can also follow the Video Cloud App SDK for Android on Twitter: http://twitter.com/bcandroidsdk or register for updates and announcements by e-mail about our mobile SDKs.