gajus / youtube-player

YouTube iframe API abstraction.
Other
369 stars 79 forks source link

Cannot force https #95

Closed jakubkoje closed 1 year ago

jakubkoje commented 2 years ago

Hello, It would be really great if we had an option to force HTTPS on the youtube.com/iframe_api call.

In my usecase, I am building hybrid app for android, and by default it uses http for local files. This way, the youtube-player will load iframe_api from http and android does not allow that by default.

Here is diff that solved my problem. It is currently hardcoded to https, but it would be really great if there was a option like forceHttps: boolean.

diff --git a/node_modules/youtube-player/dist/loadYouTubeIframeApi.js b/node_modules/youtube-player/dist/loadYouTubeIframeApi.js
index 6a7c1b9..8e540d0 100644
--- a/node_modules/youtube-player/dist/loadYouTubeIframeApi.js
+++ b/node_modules/youtube-player/dist/loadYouTubeIframeApi.js
@@ -21,9 +21,7 @@ exports.default = function (emitter) {

       return;
     } else {
-      var protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';
-
-      (0, _loadScript2.default)(protocol + '//www.youtube.com/iframe_api', function (error) {
+      (0, _loadScript2.default)('https://www.youtube.com/iframe_api', function (error) {
         if (error) {
           emitter.trigger('error', error);
         }

Thank you.