Prerequisites
Before you begin to modify your code to play adaptive content on the Hls.js Player, complete the following prerequisites to set up your app and the player:- Set up your app to use the W3C Media Player. For more information, see Media Player Setup.
-
Make the following additional updates to enable the Adaptive Playback:
-
Open the package.json in your app folder. In the
dependenciessection, include the following dependencies.
-
Open the package.json in your app folder. In the
Configure the Hls.js player for Vega
-
Download the Hls.js Player for Vega to a known location.
To download the Vega Media Player patch for a specific Hls.js version, click the corresponding version number in the following list.
- v1.5.11-r1.7 - Migrated deprecated xmldom to @xmldom/xmldom.
- v1.5.11-r1.6 - Fixes for Captions rendering.
- v1.5.11-r1.5 - Updated polyfills to support Headless JS playback. Changed imports from
@amazon-devices/react-native-w3cmediato@amazon-devices/react-native-w3cmedia/dist/headless.
-
Expand the Hls.js Player package.
For example.
tar -xzf hls-rel-v1.5.11-r1.5.tar.gz - Navigate to the /hls-rel/scripts directory.
-
Run the setup.sh helper script.
./setup.shThe setup.sh script performs a build which generates a directory named hls.js.- From the generated hls.js directory, copy the contents of the hls-rel/src/* directory to <app root>/src/*.
- From the generated hls.js directory, copy the dist directory to <app root>/src/hlsjsplayer/dist.
- From the generated hls.js directory, copy the hls-rel/polyfills directory to <app root>/src/hlsjsplayer/.
Play adaptive content
Complete the following steps to load the Hls.js Player when the Video component is mounted.To play adaptive content with Hls.js player
-
Open your src/App.tsx and replace the contents with following code.
- Use the Vega SDK to build the app, run it on device or simulator and collect logs. For more details about building and running apps on the simulator, see Create a Vega App and Vega Virtual Device.
To integrate the Hls.js player manually
-
Clone the Hls.js package from https://github.com/video-dev/hls.js.
-
Checkout the git branch based on v1.5.11 to a local branch named v1.5.11-kepler.
- Download the Vega Hls.js Player package to a known location where you will expand the file.
-
Expand the file.
-
Apply the Hls.js patches:
-
Install Hls.js dependencies by running npm install:
-
Build Hls.js Player by running npm run build
If you receive error in which the build is unable to resolve the base-64 and xmldom node modules, run the following commands to install them.
Related topics
- W3C Media Player Overview
- Play adaptive content using Dash.js Player
- Play adaptive content (HLS/DASH) with Shaka Player
- Media Player playlist playback

