Embed youtube playlist with side list tray

拥有回忆 提交于 2019-12-04 18:29:33

问题


I've been playing with the youtube embed playlist functionality with javascript.

So far when I embed a playlist it looks like this:

http://postimage.org/image/vk6fv56yx/

The blue circle shows the number of items in the playlist and when clicked the thumbnails show.

when the video starts playing is necesary to click the playlist button for the list to show, like this:

http://postimage.org/image/ezzxpy7pn/

But I want the player to show like it shows on the youtube page, like this:

http://postimage.org/image/4suta8kuh/

now this is the code Im using:

<script>
  // Load the IFrame Player API code asynchronously.
  var tag = document.createElement('script');
  tag.src = "https://www.youtube.com/player_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  // Replace the 'ytplayer' element with an <iframe> and
  // YouTube player after the API code downloads.
  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
        height: '390',
        width: '640',
        videoId: 'n2ISkJZC6DI',
        playerVars: {
                  listType:'playlist',
                  list: 'PL546E6163151751EE'
                },
        events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
        }
    });
  }

  function onPlayerReady(){
    alert('player ready');
  }

  function onPlayerStateChange(){
    alert('player changed');
  }

</script>

It works great! but I wanted to know if there is a way to change the view of the playlist tray.

Thanks a lot for your help folks :)


回答1:


You can use the flash version of the youtube embed player to achieve that look. However the tray is now positioned to the left side.

<iframe width='500' height='294' src="https://www.youtube.com/v/videoseries?list=PL546E6163151751EE"></iframe>


来源:https://stackoverflow.com/questions/15056634/embed-youtube-playlist-with-side-list-tray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!