AMP Android SDK: Basic Integration

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

The Android AMP SDK is a set of tools that allows app developers to implement video playback capabilities natively, for any Android based device (mobile or TV).


It provides a very easy integration process and offers several functionalities, such as Video and Audio playback for PMD, VOD and Live videos on different formats like HLS, DASH, SmoothStreaming, MP4, MP3, and others.


The core functionality of the player is multimedia playback, however, there is also a set of modules that include Captioning, UI Controls and several different Ads and Analytics providers.


Getting Started

This is a basic guide to integrate AMP on any Android application.



The app developer who is doing AMP's integration into their app has a working Android Studio environment; that is, they can run a "Hello World" sample in their device or emulator, that uses the latest Android APIs.


Extract the contents of the SDK package zip file.

Add the AMP SDK libraries to your project (it should be enough to copy the /modules/Core/libs folder content into the libs folder of your project).


The following steps are based on the AMPSample Android Studio project.


1. Add the VideoPlayerContainer object in your activity layout as following (attributes like width, height, paddings, margins, etc; are modifiable as any other UI component in Android):

    android:layout_gravity="center" />


2. In the onCreate() method of your activity, get a reference to the VideoPlayerContainer object; register the callback for playback and prepare the URL to be played:

protected void onCreate(Bundle savedInstanceState) {
    mVideoPlayerContainer = (VideoPlayerContainer) findViewById(;


3. In order for the callback registering to succeed, the activity must implement the

public class MainActivity extends Activity implements VideoPlayerContainer.VideoPlayerContainerCallback {


4. For the activity to be a VideoPlayerContainerCallback, it has to implement three methods: onVideoPlayerCreated()onResourceReady() and onResourceError():

public void onResourceReady(MediaResource mediaResource) {

public void onVideoPlayerCreated() {

public void onResourceError() {

Use the play(MediaResource resource) method of the VideoPlayerView object to start playing a stream; use playAudio(MediaResource resource) for audio-only streams.


5. With this callback, the SDK converts the URL of a stream into a MediaResource.


Note: The player automatically selects the appropriate decoding method for playback, according to the stream and the device used.

The recommendation is not to set any decoding mode. Here is more info on the available decoding modes.



MediaResource object

In order to play a video or an audio using AMP, you need to provide a MediaResource object as shown previously in step #4. This object is a representation of a Media Resource precisely, it contains everything the player needs to start the playback, stream URLs, including backups, titles and subtitles, captions, poster image (if provided, etc).


The player is going to provide this method to you:

public void onResourceReady(MediaResource mediaResource) {
    resource = mediaResource;
    mVideoPlayerView = mVideoPlayerContainer.getVideoPlayer();
    mVideoPlayerView.setLogEnabled(true);, mCurrentPosition);

However, if you want to manually provide any of these attributes, you can modify this object to do so. Also, if you are using Configuration files, all this information will be filled for you as well.


Audio-only playback

Some radio apps might need playback of audio-only streams. It is accomplished in a manner quite similar to video playback. There are two implementation changes:

  • Use VideoPlayerContainer.getAudioPlayer() instead of getVideoPlayer()
  • Use VideoPlayerView.playAudio(MediaResource resource) instead of play(MediaResource resource)

The recommended decoding mode for audio-only playback is AUTOMATIC (that is, do not specify a mode, for the SDK to choose the best mode available). 

Check the AMPAudioSample example project inside the /modules/Cores/samples folder for details.

2 people found this helpful