fixed setting youtube host for non-https case

This commit is contained in:
Vladimir Morozov 2019-04-04 08:51:20 +03:00
parent c202551e6d
commit f4b47a9275

View File

@ -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(
{},
{