Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
Add default skip offset to fluid player

fluid-player displays the "skip ad" button if the ad has an attribute skipoffset (see here). I'm trying to create client code that injects a default skipoffset to the ad so that I show the skip button even if the ad doesn't have a pre-configured skip interval.

I tried overriding the player's functions onBeforeXMLHttpRequestOpen and onBeforeXMLHttpRequest, and using those to inject a value to the responseXML, but because request.onreadystatechange() handles the skipoffset extraction, and onreadystatechange calls into private methods of the playerInstance, I can't override it through the external api onBeforeXMLHttpRequestOpen or onBeforeXMLHttpRequest.

Any thoughts on where I can inject this default value?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So I managed to figure out the missing bit: I was attempting to override the provided onreadystatechange by re-assigning this method with my own function, and than calling into the provided method.

onBeforeXMLHttpRequestOpen: request => {
  let defaultOnReadyStateChange = request.onreadystatechange;
  request.onreadystatechange = function () {
    if (request.responseXML != null) {
      let linearElements = request.responseXML.getElementsByTagName('Linear');
        if (linearElements != null && linearElements.length) {
          linearElements[0].setAttribute('skipoffset', '00:00:05');
        }
      }
    defaultOnReadyStateChange();
};

By doing so I would get an error because when calling into defaultOnReadyStateChange, the context of the call would change and internal attributes for xmlHttpRequest would be missing.

The solution would be the above code, but the 2nd line should be

let defaultOnReadyStateChange = request.onreadystatechange.bind(request);

This works for me just fine.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda