Asynchronous code loading and execution can bring great benefits to a Web App including:
Radiant Media Player relies internally on Promises and Async/Await concepts and many player API calls are asynchronous in nature. In this documentation we will review how to asynchronously load player library.
<div id="rmp"></div>
<script>
const script = document.createElement('script');
script.async = true;
// If video is the main content on your page you can use fetchpriority = 'high'
script.fetchpriority = 'high';
script.addEventListener('load', () => {
// Radiant Media Player library has successfully loaded - init
const src = {
hls: 'https://your-hls-url.m3u8'
};
const settings = {
licenseKey: 'your-license-key',
src,
width: 640,
height: 360
};
const elementID = 'rmp';
const rmp = new RadiantMP(elementID);
async function initRmpPlayer() {
try {
await rmp.init(settings);
} catch (error) {
console.error('error during player initialisation', error);
}
}
initRmpPlayer();
});
script.addEventListener('error', () => {
// Radiant Media Player library failed at loading - this should not be happening often
console.error('Failed to load script:', script.src);
});
script.src = 'https://cdn.radiantmediatechs.com/rmp/10.7.5/js/rmp.min.js';
document.body.appendChild(script);
</script>
©2015-2025 Radiant Media Player. All Rights Reserved.