Android AMP SDK Migration Guide: From v5 to v6

Document created by Orlando Sanchez Martinez Employee on Feb 7, 2017Last modified by Orlando Sanchez Martinez Employee on May 5, 2017
Version 6Show Document
  • View in full screen mode

This document is part of AMP Android SDK 



When migrating from an older version to our latest, the changes needed for basic playback are minor:




1) Playing a stream

Previously, the developer had to know all about the different decoding modes included in the SDK, to choose an appropriate one for the stream to be played:

// Old

String mUrl = ...;

if (mUrl.endsWith(".mp4")) {
else {


Now on v6, the SDK automatically selects the best decoding mode, according to the specific device and stream (by analyzing its metadata and MIME type).


To play the video and do this automatic analysis, there is a new async callback:


// New

mVideoContainer.addVideoPlayerContainerCallback(new VideoPlayerContainer.VideoPlayerContainerCallback() {
public void onVideoPlayerCreated() { Log.i(TAG, "onVideoPlayerCreated"); }

public void onResourceReady(MediaResource resource) {
        mVideoView = mVideoContainer.getVideoPlayer(); //Mode set automatically
        mVideoView.setLicense(LICENSE);; //Start playback

public void onResourceError() { Log.e(TAG, "onResourceError"); }

Notice you can get (or set) information about the stream on the class:

String url = resource.getResourceUrl();
String mimeType = resource.getMimeType();



2) Play a stream at a specified position (in seconds)


Apply a similar change, using the play(url, position) method of the async callback.

Previously, the call to play was done using the URL of the stream (the first parameter is a String):

// Old

mVideoView.playUrl(mUrl, mCurrentPositionInSeconds);


Now, we use the MediaResource itself, which is received as parameter, on the onResourceReady() method, from the VideoPlayerContainerCallback:

// New, mCurrentPositionInSeconds);



3) Getting the VERSION of the AMP Library

// Old

String ampVersion = VideoPlayerView.VERSION;


// New

String ampVersion = AMPLibraryInfo.VERSION;


You can also get the library's "official name" from the AMPLibraryInfo.NAME constant.



4) Events


Here listener is of the type

We have added the possibility to add several different events listeners, and also to remove them:


// Old



// New


// some more work...




5) Decoding modes


The SDK automatically determines the best decoding mode available.
However, if you want to change it for testing, compatibility (or for any other reason), here’s how:

// Old



// New (the best practice is NOT calling this method)



Read more about the different decoding modes here.


This document is part of AMP Android SDK