Creating a Basic Android App

Learn how to quickly create a basic player app.

For this tutorial, you need:
  • The Ooyala provided PCODE. To obtain your PCODE, log into your Backlot account and navigate to Account > Developers. In your API Key, the alphanumeric characters preceding the period (".") represent the PCODE constant to use in the tutorial. For example, if the API key is xxxxxxxxxxxxxxxxxxxxxxxxxxxx.0000, then use the first 28 characters (xxxxxxxxxxxxxxxxxxxxxxxxxxxx) for the PCODE. For details, see Your API Credentials.
  • The embed code (content ID or asset ID) of a video you want to play.
  • Android Studio installed and configured on your system.
  1. Get the Basic Playback Sample App from the GitHub repository:

    Ooyala Mobile SDK for Android Sample Apps

  2. Open Android Studio and select File > Import Project.
  3. Navigate to the BasicPlaybackSampleApp and select OK. Import Project to Android Studio
  4. Open BasicPlaybackVideoPlayerActivity for editing:

    Notice the import statements. The following statements are the standard imports for any player app:

    • import;
    • import
    • import
    • import;
  5. Enter your own EMBED and PCODE values:
      final String EMBED  = "yourEmbedCodeHere";  //Embed Code, or Content ID
      final String PCODE  = "yourPcodeHere";
    Note: Leave the DOMAIN constant unchanged as This works in conjunction with Syndication Controls (publishing rules) in Backlot. If you have set Internet domain restrictions on videos in Backlot, the domain variable here can be set to one of those allowed domains. If you have not set these Syndication Controls, the DOMAIN constant here has no effect.
  6. Test the app:
    1. Click Play. Play to test the app
  7. Choose the test device or emulator and select OK. Pick Play Device
  8. Navigate the unlock options for the test device and select a Basic Playback option. Select Play Option

The video plays.

Video Plays

Study the code elements used to initialize the player:

Table 1. Initializing the Player
Description Sample Code

Set the layout to the OoyalaPlayerLhayout.

Note: For more about layouts, see Layout Controls
OoyalaPlayerLayout playerLayout = (OoyalaPlayerLayout) findViewById(;

Create an OoyalaPlayerController object (named playerLayoutController).

playerLayoutController = new OoyalaPlayerLayoutController(playerLayout, PCODE, new PlayerDomain(DOMAIN));

Instantiate a player object with the playerLayoutController.getPlayer() method.

 player = playerLayoutController.getPlayer();

The if test with player.setEmbedCode() function with the identifier of the video to play (hEMBED).

Note: For more sophisticated applications, rather than hard coding the video identifier, pass a variable to the setEmbedCode() function.

    if (player.setEmbedCode(EMBED)) {;
    else {
      Log.e(TAG, "Asset Failure");