Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!