Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
JW Player livestream failover, midstream switching to backup CDN

I can't get it to make a seamless transition to a backup CDN while a livestream is running, in case the primary CDN goes down. I am using two different providers with HLS m3u8-URL. I don't want a playlist solution with EXT-X-STREAM-INF (which HLS can do), because I have to change the stream URL very often and the providers are completely different, with partly different quality/resolution levels and also different bitrates.

From the JW Player support I received this code for embedding the player:

<script defer src="https://cdn.jwplayer.com/libraries/my-personal-player.js"></script>

<div id="player"></div>
    
    <script type="text/JavaScript">
        window.addEventListener("DOMContentLoaded", () => {
        var player = jwplayer("player").setup({
            "width": "100%",
            "playlist": [
            {
                "sources": 
                [
                {
                    "file": "https:.../.../main.m3u8",
                },
                ]
            }
            ],
        });

        var playlistRedundant = {
                "sources": 
                [
                {
                    "file": "https:.../.../backup.m3u8",
                },
                ]
            }
        var interval;

        player.on('error', (e) => {
            console.log(e)
            player.getContainer().getElementsByClassName('jw-error-text')[0].innerHTML = "Custom error message - at the moment no livestream"
            if (e.code == 232404 && !interval) {
                var intervalCounter = 0
                interval = setInterval(() => {
                    if (intervalCounter < 3) {
                        player.load(playlistRedundant)
                        player.play()
                        player.on('play', (e) => {
                            console.log(e)
                            clearInterval(interval)
                        })
                        intervalCounter += 1
                        console.log(intervalCounter)
                    } else {
                        clearInterval(interval)
                    }
                }, 3000);
            }
        })
    })
    </script>

The code is actually quite good. If the main stream is not there, then it tries 3 times to load the backup stream. But in the time it already brings the custom error message. This works fine if the main stream is already not there when the page is loaded. But if the main stream starts and fails during the stream, then nothing happens. You have to reload the page and then it goes to the backup stream. However, the desired transition is as seamless as possible without the user having to do a page refresh himself.

Unfortunately, the support could not help me any further. I have tried other approaches, but they did not work either. Does anyone have an idea? Thanks a lot!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda