diff options
author | Vladimir Morozov <freezer278@gmail.com> | 2019-04-04 08:51:20 +0300 |
---|---|---|
committer | Vladimir Morozov <freezer278@gmail.com> | 2019-04-04 08:51:20 +0300 |
commit | f4b47a9275d597f7f3eb47dbc89603859be166f9 (patch) | |
tree | 19e57ddadc1460e3971e8964e748abc0407251ca /src | |
parent | c202551e6d0b11656a99b41f3f8b3a48f2bf1e0a (diff) | |
download | plyr-f4b47a9275d597f7f3eb47dbc89603859be166f9.tar.lz plyr-f4b47a9275d597f7f3eb47dbc89603859be166f9.tar.xz plyr-f4b47a9275d597f7f3eb47dbc89603859be166f9.zip |
fixed setting youtube host for non-https case
Diffstat (limited to 'src')
-rw-r--r-- | src/js/plugins/youtube.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js index d5972c80..cac1a90f 100644 --- a/src/js/plugins/youtube.js +++ b/src/js/plugins/youtube.js @@ -34,6 +34,22 @@ function assurePlaybackState(play) { } } +function useHttp() { + return !window.location.href.includes('https://'); +} + +function getYoutubeHost(config) { + let host; + + if (config.noCookie) { + host = 'https://www.youtube-nocookie.com'; + } else { + host = useHttp() ? 'http://www.youtube.com' : undefined; + } + + return host; +} + const youtube = { setup() { // Add embed class for responsive @@ -151,7 +167,7 @@ const youtube = { // https://developers.google.com/youtube/iframe_api_reference player.embed = new window.YT.Player(id, { videoId, - host: config.noCookie ? 'https://www.youtube-nocookie.com' : undefined, + host: getYoutubeHost(config), playerVars: extend( {}, { |