AMP Android SDK: CEA-608 Close Captions integration

Document created by Orlando Sanchez Martinez Employee on Dec 28, 2016Last modified by Herberth Alvarado on Apr 9, 2017
Version 4Show Document
  • View in full screen mode

Prerequisite

The rest of this guide assumes you have successfully integrated AMP's Core (you are able to play back a video).

 

Getting started

For reference, check the AMPCaptioningSample Android Studio sample project in the release package.
To integrate the plugin into your app, you need to:

 

1) Add the amp-closed-captions.jar to your project's /libs folder.
 

2) In the Activity where playback is handled, import the following Java packages:

import com.akamai.captioning.CaptionComponent;
import com.akamai.captioning.CaptioningWrapper;

 

3) Add an object of the CaptionComponent type in your Activity's members:

private CaptionComponent captionComponent;
private CaptioningWrapper captioningWrapper;

 

4) The CaptionComponent is of the android.widget.RelativeLayout type, so it must be declared in the Activity's .xml in the /layout folder:

<com.akamai.captioning.CaptionComponent
   android:id="@+id/captionView"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:clickable="false" />

 

5) To initialize the CaptionComponent, add this to your Activity's onCreate() method:

captionComponent = (CaptionComponent) rootView.findViewById(R.id.captionView);

 

6) Initialize the CaptionComponent and CaptioningWrapper objects, on the onResourceReady() method from the VideoPlayerContainerCallback:

private void createCaptions(){
   captioningWrapper = new CaptioningWrapper(captionComponent);
   captioningWrapper.setVideoPlayerView(videoPlayerView);
   captionComponent.setVideoPlayerView(videoPlayerView);

   captionComponent.setCaptionTextStyle(CaptionComponent.CAPTION_TEXT_NORMAL_STYLE);
   captionComponent.setTextSize(18);
   captionComponent.setTextBackgroundColor(Color.BLACK);
   captionComponent.setTextColor(Color.WHITE);
   //captionComponent.setTextWindowColor(Color.CYAN);
   //captionComponent.setCaptionAnimationMode(CaptionComponent.CAPTION_ANIMATION_ROLL_UP);

   //Typeface tf = Typeface.createFromAsset(this.getAssets(), "fonts/Arial Black.ttf");
   //captionComponent.setTypeface(tf);
}

 

 

 

If you have any question or comment, reach out to us via email: amp-sdk-support@akamai.com

1 person found this helpful

Attachments

    Outcomes