jfujita / videojs-http-source-selector

VideoJS plugin that leverages videojs-contrib-quality-levels plugin to offer manual user-select able level selection options for adaptive http streams.
MIT License
62 stars 49 forks source link

Source selector fails to initialize when the full-screen toggle is disabled #52

Open yurique opened 4 years ago

yurique commented 4 years ago

I have full-screen button disabled and getting an exception like this in the console:

VIDEOJS: ERROR: TypeError: Cannot read property 'el' of undefined

I believe the root of the issue is here:

      player.videojs_http_source_selector_initialized = true;
      var controlBar = player.controlBar,
          fullscreenToggle = controlBar.getChild('fullscreenToggle').el();
      controlBar.el().insertBefore(controlBar.addChild('SourceMenuButton').el(), fullscreenToggle);

Changing it to

        var controlBar = player.controlBar,
            fullscreenToggle = controlBar.getChild('fullscreenToggle');
        if (fullscreenToggle) {
          controlBar.el().insertBefore(controlBar.addChild('SourceMenuButton').el(), fullscreenToggle.el());
        } else {
          controlBar.el().appendChild(controlBar.addChild('SourceMenuButton').el());
        }

Fixes the issue, I'll open a PR in a sec.

hlibmykhailov commented 3 years ago

Please, approve this solution!