The best practice is not to set any decoding mode, since the AMP SDK automatically selects the appropriate decoding method for playback, according to the stream and the device used.
However, if you need to manually select one of the available modes (for testing, compatibility or other reasons), use the following line:
The videoPlayerContainer.setDefaultMode() method must be invoked before the videoPlayerContainer.getVideoPlayer() method, in the first lines of the onResourceReady() method of the callback.
playerMode should be one of the following constants (corresponding to the decoding methods detailed below):
The decoding modes available in the Android SDK are:
- It's the default mode of the player.
- Used for HLS, DASH, Smooth Streaming and PMD playback.
- The decoding job is done by our own modified version of the ExoPlayer Library.
- This library has been integrated in a way that won't collide or have any problem with any other ExoPlayer version your app might be using.
- This is the recommended mode for most scenarios.
- It's compatible with Android OS 4.1 and above.
Hardware Advanced mode
- It’s AMP's own HLS decoding mode.
- It is fully functional in all our versions, but it's deprecated now.
- It provides fast startup times, hardware acceleration and support for automatic bitrate switching (adaptive bitrate).
- Available for devices Android 4.0 and above.
Native basic mode
- Using this mode, the Android SDK will directly use the native player implemented by Android.
- It is a wrapper to the system's own multimedia playback capabilities.
- Due to the different implementations of the native player in the different versions of Android, this mode will not be available on multiple devices.
- Furthermore, this mode presents some restrictions, due to the fact the Android OS doesn't report back to the SDK some data that is available in other modes.
Android SDK will use the H.264 decoder chipset present in any Android device (version 1.6 and on) for decoding video/audio of the stream.
The quality offered by this method is much better than the one you can get using software based decoding, although this method has the same limitations of the H.264 decoding chipset: not supporting other H.264 profiles than Baseline. Automatic bitrate switching is not supported in this mode.
To enable Hardware decoding, the com.akamai.media.hls.AkamaiHLSService service must be declared in the Android Manifest file inside the application section:
<service android:name="com.akamai.media.hls.AkamaiHLSService" />
Android SDK will use software based codecs for decoding the video/audio of the stream, on older devices (compatible with Android 1.6 and above).
Since it's using software, CPU consumption will be higher than when using hardware based decoding.
As an advantage, this method is free of any restriction of the device regarding video encoding limitations. Automatic bitrate switching is supported.
This mode follows the next logic to determine the decoding method to be used:
- For MPEG-Dash, SmoothStreaming, or PMD: EXO mode is selected
- For HLS
- For Android OS 4.1 or above: EXO mode is selected.
- For Android OS 4.0 or above: Hardware Advanced mode is selected.
- If it’s an Android OS below 4.0:
- If the number of cores inside the CPU of the device is 2 or higher: Software mode is selected
- If the CPU of the device contains a single core: Hardware mode is selected.
- If it’s an Android OS below 4.0: