react-player icon indicating copy to clipboard operation
react-player copied to clipboard

When i passin link to youtube that has playlist on, it does not working=(

Open againksy opened this issue 8 years ago • 6 comments

https://www.youtube.com/watch?v=4l8Wkrb5JNw&list=PLSmhG8yDCXaFj04Rag9btia4G3nN3hFRn for example- nothing happens...

againksy avatar Feb 05 '18 16:02 againksy

Great work! I was going to ask about playlist support as well. @CookPete - Is this something you plan to support?

iladarsda avatar Feb 06 '18 10:02 iladarsda

You can do this using the config prop to set certain playerVars:

<ReactPlayer
  url='https://www.youtube.com/watch?v=4l8Wkrb5JNw'
  config={{ youtube: { 
    playerVars: {
      listType:'playlist',
      list: 'PLSmhG8yDCXaFj04Rag9btia4G3nN3hFRn'
    }
  }}}
/>

https://jsfiddle.net/hLjjhyog/

cookpete avatar Feb 06 '18 10:02 cookpete

Amazing, thanks for the info.

iladarsda avatar Feb 06 '18 11:02 iladarsda

I suppose it would be handy to parse list= in the url prop and set the playerVars automatically. I'll look into it.

cookpete avatar Feb 06 '18 11:02 cookpete

@CookPete The below code doesn't work

<ReactPlayer
          url='https://www.youtube.com/embed?'
          config={{ youtube: { 
            playerVars: {
              listType:'search',
              list: 'likey'
            }
          }}}
          controls
        />

edwinharly avatar Jul 19 '18 14:07 edwinharly

@edwinharly Yeah that kind of sucks. With how things work, you have to pass in a valid Youtube URL for the Youtube player to kick in, but obviously when you want to search, you don't know what you want to play first...

A very hacky workaround would be to set the URL as a very short blank video, which will play and finish quickly, then play the search results, eg:

<ReactPlayer
  url='https://www.youtube.com/watch?v=jhFDyDgMVUI'
  config={{ youtube: { 
    playerVars: {
      listType:'search',
      list: 'likey'
    }
  }}}
  controls
/>

This is not ideal though, so I will look for a better fix.

cookpete avatar Dec 05 '18 15:12 cookpete