Using the QoS Solution Powered by NPAW for Android

The mobile implementation of the Ooyala QoS Solution powered by the NicePeopleAtWork (NPAW) YOUBORA platform provides analytics for events on Ooyala's Android players.

Before implementing the Ooyala QoS Solution powered by YOUBORA, you should have:
  • A customer relationship with NPAW that includes accounts for YOUBORA. Ask your Ooyala contact person for an NPAW account ID and User ID for the device.
  • A Ooyala Backlot account.
  • Experience in Android development.
To integrate NPAW's YOUBORA with an existing Ooyala Player application, add some plugin code to your project and add some code snippets to your code.
  1. Log in to http://youbora.com/.
  2. Download http://smartplugin.youbora.com/v5/android/ooyala/5.3.0/libs.zip.
  3. Extract the contents of libs.zip and import the jar files into your Android Studio project.
  4. Add the following import statement to the code that creates the Ooyala player. (In the the Ooyala example, this code goes in BasicPlaybackVideoPlayerActivity.)
    import com.npaw.youbora.plugins.PluginOoyala;
  5. Create a field to hold the plugin instance in this class:
    private PluginOoyala pluginOoyala;
  6. As soon as the player is created, instance the plugin and start monitoring the player. This is usually done in the onCreate method.
    pluginOoyala = new PluginOoyala(options);
    pluginOoyala.startMonitoring(player);
    The options argument is a Map that includes information related to the client YOUBORA account, device information, media info, and other things. For more information about these options, see our developer portal.

    The startMonitoring() method registers the listeners and observers that extract events from the player. It creates a session in YOUBORA when the player loads the media.

  7. Insert code that stops tracking analytics, call stopMonitoring() when, for example, the end user stops the fullscreen player. Place stopMonitoring() in the “back button” or onBackPressed() method. Or, override Activity's onStop() and check for the isFinishing() result. For example:
    @Override
    protected void onStop() {
     super.onStop();
     Log.d(TAG, "Player Activity Stopped");
     if (player != null) {
     player.suspend();
     }
     if (isFinishing()) {
     pluginOoyala.stopMonitoring();
     }
    }
    The stopMonitoring() method unregisters everything set by the startMonitoring() method, and also sends a /stop event that closes any ongoing YOUBORA sessions.
  8. To pause and resume monitoring, such as when the user goes away from the app, use pauseMonitoring(). This ensures that the app does not send pings while it is in the background. This is usually done from the Activity's onStop() method, if isFinishing() returns false.
    @Override protected void onStop() {
      super.onStop();
      Log.d(TAG, "Player Activity Stopped");
      if (player != null) {
        player.suspend();
      }
      if (isFinishing()) {
        pluginOoyala.stopMonitoring();
      } else {
        pluginOoyala.pauseMonitoring();
      }
    }
    Call resumeMonitoring() when the user comes back from background. This method re-enables pings and any periodic operations. This is done in the Activity's onRestart() method.
    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d(TAG, "Player Activity Restarted");
        if (player != null) {
            player.resume();
        }
        pluginOoyala.resumeMonitoring();
    }
  9. To enable logs, If you want the plugin to print logs, call YBLog.setDebugLevel() before anything else, prior to the plugin creation.
    YBLog.setDebugLevel(logLevel);

    Where logLevel is one of the following constants defined in the YBLog class (ordered by verbosity:

    • YBLogLevelSilent

    • YBLogLevelError

    • YBLogLevelWarning
    • YBLogLevelLifeCycle
    • YBLogLevelDebug
    • YBLogLevelHTTPRequests
    You can download a fully integrated example from http://smartplugin.youbora.com/v5/android/ooyala/5.3.0/example.zip.
  10. (Optional) You can supplement or customize the metadata the app sends to NPAW.
    YouboraMetadata metadata = new YouboraMetadata();
     /*
    * YouboraMetadata
    */
     metadata.setParam1("ooyala1");
     metadata.setParam2("ooyala2");
     metadata.setCdn("Akamai");
     metadata.setIp("8.8.4.4");
     metadata.setIsp("Telefonica");
     metadata.setTransaction("ooyala-transaction");
     metadata.setResource("http://1234");
     
     /*
      * Youbora metadata map
      */
     Map<String, String> metadataMap = new HashMap<String, String>();
     metadataMap.put("title", "custom title");
     metadataMap.put("genre", "genre");
     metadataMap.put("language", "langugae");
     metadataMap.put("year", "year");
     metadataMap.put("cast", "cast");
     metadataMap.put("director", "director");
     metadataMap.put("owner", "owner");
     metadataMap.put("duration", "10000");
     metadataMap.put("parental", "parental");
     metadataMap.put("price", "1000");
     metadataMap.put("rating", "100");
     metadataMap.put("audioType", "6");
     metadataMap.put("audioChannels", "2");
     
     /*
      * Youbora device metadata map
      */
     Map<String, String> deviceMap = new HashMap<String, String>();
     deviceMap.put("manufacturer", "manufacturer");
     deviceMap.put("type", "type");
     deviceMap.put("year", "year");
     deviceMap.put("firmware", "firmware");
     /*
      * Youbora properties map
      */
     Map<String, Object> properties = new HashMap<String, Object>();
     properties.put("filename", "filename");
     properties.put("content_id", "content_id");
     properties.put("transaction_type", "transaction_type");
     properties.put("quality", "quality");
     properties.put("content_type", "content_type");
     properties.put("custom property1", "custom property 1");
     
     /*
      * Put the override maps into the properties before updating
      */
     properties.put("content_metadata", metadataMap);
     properties.put("device", deviceMap);
     /*
      * Put the combined properties map into the YouboraMetadata
      */
     metadata.setProperties(properties);
     Youbora.updateYouboraMetadata(metadata);
                     

    YouboraMetadata

    A class that accepts metadata about the environment. This is added into YOUBORA using Youbora.updateYouboraMetadata(metadata);.

    This class has (but is not limited to) the following methods. For a full list of keys you can use along with detailed descriptions and examples, see the YOUBORA product documentation.

    Method Automatically Filled Description
    YouboraMetadata.setParam1 No  
    YouboraMetadata.setParam2 No  
    YouboraMetadata.setCdn No

    Allows you to override the CDN automatic detection that YOUBORA Analytics does. This is an optional method.

    The CDN detection is done based on the host of the resource/video URL YOUBORA receives from the player. However, you could embed API URLs that may cause YOUBORA automatic system to return a wrong CDN (or unknown). If you use the YOUBORA Smartswitch or know which CDN is sending the content, you can override the automatic value.

    YouboraMetadata.setIp No

    Allows you to override the IP automatic detection that Analytics does. This is an optional method.

    The IP comes from the request IP from the end user. If you use a middle-ware between the plugin and the analytics server for the Smartswitch feature, YOUBORA would only get the middleware IP instead of the user's.

    YouboraMetadata.setIsp No

    Allows overriding the ISP automatic detection that Analytics does. This is an optional method.

    YouboraMetadata.setTransaction No Sets the transaction code value inside YOUBORA analytics. The transaction code is a specific code you can use to identify the view within the Analytics tool and make searches. This code means whatever you want it to (purchaseCode, sessionCode, and so on).
    YouboraMetadata.setResource No Overwrites the video URL metadata sent to the YOUBORA system. This means that even though the player plays one different URL, you can set up a new one as metadata (not as the video that will be played) just for the CDN detection.

    Properties Map

    A HashMap of properties that contains information about the current playback. Added into YOUBORA using metadata.setProperties(), where metadata is a YouboraMetadata object. This HashMap accepts (but is not limited to) the following keys. For a full list of keys you can use along with detailed descriptions and examples, see the YOUBORA product documentation.
    Key Automatically Filled Description
    filename No File name of the current media content.
    content_id Yes Defaults to the Ooyala Embed Code/Content ID.
    transaction_type No Rent: Media for rental.

    Subscription: Media which has been acquired as part of a subscription.

    EST (Electronic Sell Through): Media purchased.

    Free: Media which has no economical transaction.

    quality No HD or SD.
    content_type No Trailer, Episode, or Movie.
    content_metadata Yes A HashMap of many other metadata entries related to the content.
    device Yes A HashMap of many other metadata entries related to the content.
    <Any text> No Can be any text string, which would be passed through to NPAW.

    MetadataMap

    A HashMap of information about the content. Added into the properties HashMap using properties.put("content_metadata", metadataMap); This HashMap accepts (but is not limited to) the following keys. For a full list of keys you can use along with detailed descriptions and examples, see the YOUBORA product documentation.
    Key Automatically Filled
    title Yes
    genre No
    language No
    year No
    cast No
    director No
    owner No
    duration Yes
    parental No
    price No
    rating No
    audioType No
    audioChannels No

    Device Metadata Map

    A HashMap of information about the device This HashMap accepts (but is not limited to) the following keys. For a full list of keys you can use along with detailed descriptions and examples, see the YOUBORA product documentation.

    Key Automatically Filled
    manufacturer No
    type No
    year No
    firmware No
When you have configured Ooyala and Youbora correctly, you will be able to see NPAW requests in network traces going to http://test-nqs.nice264.com/, as well as see logs in Logcat tagged with NICE_PEOPLE_OOYALA and NICE_PEOPLE_BASE.
In our public Android Sample Apps Github repository you can find a sample application with two examples.
  1. The minimum required configuration.
  2. A configuration using all optional parameters.

Was this article helpful?