brightcove / player-loader

An asynchronous script loader and embed generator for the Brightcove Player.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

expecting bc to be on the window

malplayer opened this issue · comments

when dowloading the bc player script it has this code in it

 // Use Node, AMD or browser globals to define a module.
  // See umd/returnExports
  (function (root, factory) {
    if (typeof define === 'function' && define.amd) {
      // AMD. Register as 'bc'
          define('bc', [], function() {
            var result = factory.apply(this, arguments);
            root.videojs.log.warn('DEPRECATION: Using the default named RequireJS module in the Brightcove Player is deprecated. See: https://support.brightcove.com/requirejs-and-brightcove-player#Future_implementation');
            return result;
          });
    } else if (typeof exports === 'object') {
      // Node. Does not work with strict CommonJS, but
      // only CommonJS-like environments that support module.exports,
      // like Node.
      module.exports = factory();
    } else {
      // Browser globals (root is window)
      root.bc = factory(root);

and the loader has this

const initPlayer = (params, embed, resolve, reject) => {
  const {embedId, playerId} = params;
  const bc = window.bc[`${playerId}_${embedId}`] || window.bc;

the loader expect the bc player to be on the window object. can you provided an option for the loader to use require js or some loader to get the bc if the consuming app is using require js

This is still an issue for me. When I try to display the BC video in the wrapping iframe, window.bc is undefined

Still an issue for me too, I'm using NextJS. window.bc is not defined even when trying to load it in useEffect.