Start a new topic
Answered

Switching viblast.js to CDN

Since switching `viblast.js` to be served by our CDN instead of directly from our webapp we have noticed that it no longer plays. The filenames are all the same (viblast.js as oppposed to viblast-xyz.js). The only different has been to serve the asset from a different address (`xyz.cloudfront.com/assets/viblast.js` as opposed to `/assets/viblast.js`).

Before we were able to get away without server `worker.html` (viblast would never request it). We can get the video playing with the viblast files served from the CDN if we provide `worker.html` as well (previously this was never available).

  1. Do you know why we would now need `worker.html`?
  2. How does viblast choose whether worker is required?
  3. How can we get this working without requiring `worker.html

Thanks

Theo`

Best Answer

Hi Therese,


> 1. Do you know why we would now need `worker.html`?


Viblast Player starts a javascript worker from the viblast.remuxer.js file. When you move the files to a different domain (xyz.cloudfront.com) the browser enforces the same-origin policy that prevents the viblast.remuxer.js from being loaded. In order to circumvent this limitation, Viblast Player uses the worker.html in an iframe and proxies all the requests to the worker through the iframe. This fixes the problem without requiring any effort from the client.


> 2. How does viblast choose whether worker is required?


Viblast Player looks at the domain of the current page and the domain of the viblast.js resource. If they are different then worker.html is loaded.


> 3. How can we get this working without requiring `worker.html


Currently the only option is for the viblast.js resource to be served from the same domain as the webpage itself.


worker.html is invisible and must not break page design. Have you encountered any problems with it apart from the need for the file to be present on your CDN? Theoretically it is be possible worker.html not to be loaded if CORS is enabled for viblast.remuxer.js but this is currently not supported because most CDNs don't enable CORS by default.


Svetlin


Hi Svetlin,


That explains everything.


Thanks


Theo

Answer

Hi Therese,


> 1. Do you know why we would now need `worker.html`?


Viblast Player starts a javascript worker from the viblast.remuxer.js file. When you move the files to a different domain (xyz.cloudfront.com) the browser enforces the same-origin policy that prevents the viblast.remuxer.js from being loaded. In order to circumvent this limitation, Viblast Player uses the worker.html in an iframe and proxies all the requests to the worker through the iframe. This fixes the problem without requiring any effort from the client.


> 2. How does viblast choose whether worker is required?


Viblast Player looks at the domain of the current page and the domain of the viblast.js resource. If they are different then worker.html is loaded.


> 3. How can we get this working without requiring `worker.html


Currently the only option is for the viblast.js resource to be served from the same domain as the webpage itself.


worker.html is invisible and must not break page design. Have you encountered any problems with it apart from the need for the file to be present on your CDN? Theoretically it is be possible worker.html not to be loaded if CORS is enabled for viblast.remuxer.js but this is currently not supported because most CDNs don't enable CORS by default.


Svetlin

Login to post a comment