Merge pull request #1292 from omarkhatibco/master

Support Youtube NoCookie mode
This commit is contained in:
Sam Potts 2019-01-06 14:10:25 +11:00 committed by GitHub
commit 6be125db87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -400,11 +400,14 @@ const defaults = {
enabled: false, enabled: false,
publisherId: '', publisherId: '',
}, },
// YouTube nocookies mode
noCookie: false,
// Preview Thumbnails plugin // Preview Thumbnails plugin
previewThumbnails: { previewThumbnails: {
enabled: false, enabled: false,
} },
}; };
export default defaults; export default defaults;

View File

@ -19,7 +19,7 @@ export const types = {
*/ */
export function getProviderByUrl(url) { export function getProviderByUrl(url) {
// YouTube // YouTube
if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/.test(url)) { if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(url)) {
return providers.youtube; return providers.youtube;
} }

View File

@ -153,6 +153,7 @@ const youtube = {
// https://developers.google.com/youtube/iframe_api_reference // https://developers.google.com/youtube/iframe_api_reference
player.embed = new window.YT.Player(id, { player.embed = new window.YT.Player(id, {
videoId, videoId,
host: player.config.noCookie ? 'https://www.youtube-nocookie.com' : undefined,
playerVars: { playerVars: {
autoplay: player.config.autoplay ? 1 : 0, // Autoplay autoplay: player.config.autoplay ? 1 : 0, // Autoplay
hl: player.config.hl, // iframe interface language hl: player.config.hl, // iframe interface language