A Closer Look at the Android Integration Sample App

To build your own app using the sample, consider the following sample app configuration points:

Setup the Library for Your Project

For a new project, be sure to put the following jar files in the lib or libs directory:
  • OoyalaSDK.jar: the jar file from the baseline Ooyala Mobile SDK for Android
  • OoyalaFreeWheelSDK.jar: The jar file from the Ooyala SDK for Google IMA on Android
  • ima-android-sdk-*.jar. Google IMA Libraries from the Google Developer website. The star (*) represents the file version
  • FWAdManager.jar: the jar file downloaded from the FreeWheel website

Edit the AndroidManifest.xml File

In the AndroidManifest.xml file, add the android:configChanges attribute (see highlighted line below) on the applications' <activity> declaration.

Note: This is only required if you use the OptimizedOoyalaPlayerLayoutController, which is recommended. This is discussed further below.

    android:configChanges="orientation|keyboardHidden" >

The Source for the Sample App

Open the FreeWheelSampleApp/src/ooyala/com/android/freewheelsampleapp/FreeWheelSampleAppActivity.java file.

The Imports

Examine the import statements at the top of the file:

  • The first two import statements pull in standard Java definitions for Map and HashMap.
  • The next two pull in definitions for the OoyalaFreeWheelManager and the sample application.
  • The next three are standard Android imports.
  • The final three pull definitions for player layouts and optimized layout controllers from the baseline Ooyala Mobile SDK for Android.
import java.util.HashMap;
import java.util.Map;

import com.ooyala.android.freewheelsdk.OoyalaFreeWheelManager;
import com.ooyala.android.freewheelsampleapp.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import com.ooyala.android.OoyalaPlayer;
import com.ooyala.android.OoyalaPlayerLayout;
import com.ooyala.android.OptimizedOoyalaPlayerLayoutController;        

The Constants

The topic Creating a Basic Android App introduces the constants PCODE, EMBED, and new PlayerDomain(DOMAIN), which are further discussed in See the FreeWheel Sample App in Action on Android.
  final String EMBED  = "RlODZyZDr93PAbk-a9fY7Phq93pA-Uwt";
  final String PCODE  = "5idHc6Pt1kJ18w4u9Q5jEwAQDYCH";
  final String new PlayerDomain(DOMAIN) = "http://www.ooyala.com";
Whereas the sample app defines these as constants, you probably want to define variables, especially for the EMBED constant (asset ID or content ID).

Set Up the Controller, Initialize the OoyalaFreeWheelManager and Classes

Various layout controllers combined with the OoyalaFreeWheelManager are included with the SDK. The basic views you can choose from are included in the baseline Mobile SDK for Android.

Note: For working with FreeWheel, it is highly recommended that you use the OptimizedOoyalaPlayerLayoutController layout controller.

In the sample app, a layout controller is declared of type OptimizedOoyalaPlayerLayoutController.

Finally, the freewheelManager object is initialized as type OoyalaFreeWheelManager with this activity and the layout controller:

  public void onCreate(Bundle savedInstanceState) {
    OoyalaPlayerLayout playerLayout = (OoyalaPlayerLayout) findViewById(R.id.ooyalaPlayer);
    playerLayoutController = new OptimizedOoyalaPlayerLayoutController(playerLayout, PCODE, new PlayerDomain(DOMAIN));
    OoyalaPlayer player = playerLayoutController.getPlayer();

    //Initialize FreeWheel Ad Manager
    freewheelManager = new OoyalaFreeWheelManager(this, playerLayoutController); 
For reference documentation about the OoyalaFreeWheelManager, see the OoyalaFreeWheelSDK-Android/Documentation subdirectory.

FreeWheel Parameters

For background, see the discussion in Essential Parameters and FreeWheel OPF Module Ad Set. The two parameters highlighted below must be set in your app itself.

//Set FreeWheel parameters.  Note that these are optional, and override configurations set in Backlot or Ooyala internals
Map<String, String> freewheelParameters = new HashMap<String, String>();
//freewheelParameters.put("fw_android_mrm_network_id", "90750");
freewheelParameters.put("fw_android_ad_server", "http://demo.v.fwmrm.net/");
freewheelParameters.put("fw_android_player_profile", "90750:ooyala_android");
//freewheelParameters.put("fw_android_site_section_id", "ooyala_test_site_section");
//freewheelParameters.put("fw_android_video_asset_id", "ooyala_test_video_with_bvi_cuepoints");
//freewheelParameters.put("FRMSegment", "channel=TEST;subchannel=TEST;section=TEST;mode=online;player=ooyala;beta=n");


Play the Video

Finally, the video is played with the setEmbedCode() method, which comes with the baseline Mobile SDK:

    if (player.setEmbedCode(EMBED)) {
    } else {
      Log.d(this.getClass().getName(), "Something Went Wrong!");

Was this article helpful?