AMP Android SDK: Bitrate switching

Document created by Herberth Alvarado Champion on Aug 11, 2016Last modified by Herberth Alvarado Champion on Apr 9, 2017
Version 5Show Document
  • View in full screen mode

Maintainer: Orlando Sanchez Martinez

This document is part of AMP Android SDK 


Automatic bitrate switching is supported by two modes: MODE_SOFTWARE and MODE_HARDWARE_ADVANCED. MODE_HARDWARE_ADVANCED mode is compatible with Android devices 4.0 and above.


MODE_HARDWARE is compatible with Android device 1.6 and above. It doesn’t support automatic bitrate switching, but it offers a full set of methods to let the application configure the bitrates used during the playback:



Methods for bitrate switching


setHLSStartingAlgorithm(mode): Sets the algorithm used for selecting the initial playback bitrate. There are two options available:

  • HLS_STARTING_ALGORITHM_APPLE Algorithm will be similar to the one used by iDevices: the first bitrate defined in the playlist is chosen as the initial bitrate.
  • HLS_STARTING_ALGORITHM_AKAMAI Algorithm designed by Akamai, optimized to cover the maximum number of devices. Chooses the highest available bitrate, below 300 Kbps. The limit of 300 Kbps can be modified using the method setAkamaiAlgorithmValue(int bitrate) – in bps.


setMaxBitrate(newMaxBitrate) Sets the maximum bitrate available for the playback. When using the HLS_STARTING_ALGORITHM_AKAMAI algorithm for selecting the initial bitrate, the SDK will choose as the initial bitrate the highest bitrate below the bitrate defined in newMaxBitrate.


switchBitrateUp() Switches to the next higher bitrate.


swithBitrateDown() Switches to the next lower bitrate.


setBitrateToPlay(value) Hardware & Hardware Advanced mode: sets the bitrate index to play. Software Mode: Switches to the highest bitrate below or equal to the one passed as parameter.


setStartingBitrateIndex(index) Sets index of the bitrate to be used when playback starts. Index 0 will be assigned to the first bitrate defined in the master playlist (typically master.m3u8), Index 1 to the second bitrate, Index 2 to the third bitrate, etc.


getBitratesCount() [int] Returns the number of bitrates available for the current stream.


getCurrentBitrate() [long] Returns the bitrate used for the playback in bps.


getBitrateByIndex(index) [long] Given a bitrate index, return bitrate in bps.



This document is part of AMP Android SDK