From 993d15bd9869daa0451f868cf9004c6c0a676897 Mon Sep 17 00:00:00 2001 From: albanqoku Date: Wed, 2 Jan 2019 08:46:58 +0000 Subject: [PATCH] Youtube playlist fixes Follow up to https://github.com/CookPete/react-player/pull/541 --- src/demo/App.js | 1 + src/players/YouTube.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/demo/App.js b/src/demo/App.js index 643e513..bf76760 100644 --- a/src/demo/App.js +++ b/src/demo/App.js @@ -221,6 +221,7 @@ class App extends Component { {this.renderLoadButton('https://www.youtube.com/watch?v=oUFJJNQGwhk', 'Test A')} {this.renderLoadButton('https://www.youtube.com/watch?v=jNgP6d9HraI', 'Test B')} + {this.renderLoadButton('https://www.youtube.com/playlist?list=PLDEcUiPhzbjI217qs5KgMvbvx6-fgY_Al', 'Playlist')} diff --git a/src/players/YouTube.js b/src/players/YouTube.js index afc96a0..105fa1f 100644 --- a/src/players/YouTube.js +++ b/src/players/YouTube.js @@ -12,7 +12,6 @@ const MATCH_PLAYLIST = /list=([a-zA-Z0-9_-]+)/ function parsePlaylist (url) { if (MATCH_PLAYLIST.test(url)) { const [, playlistId] = url.match(MATCH_PLAYLIST) - console.log(playlistId) return { listType: 'playlist', list: playlistId @@ -31,6 +30,10 @@ export class YouTube extends Component { const { playerVars } = config.youtube const id = url && url.match(MATCH_URL)[1] if (isReady) { + if (MATCH_PLAYLIST.test(url)) { + this.player.loadPlaylist(parsePlaylist(url)) + return + } this.player.cueVideoById({ videoId: id, startSeconds: parseStartTime(url) || playerVars.start,