最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to hide youtube's big red play button with a parameter? - Stack Overflow

programmeradmin4浏览0评论

Quick example of the code I'm using at the moment to create my YouTube iframe:

player = new YT.Player('[PLAYER ID]', {
  height: '300',
  width: '480',
  videoId: '[VIDEO ID]',
  playerVars: { 'controls': 0, 'showinfo': 0 },
});

It's all working great so far, it's loading the video fine without controls or the info strip and I'm 'manually' playing the video using javascript.

The problem is that there's now no need for the big red 'play' button that is momentarily displayed as the video's starting.

Is there any way I can get rid of this? I've looked through the documentation and can't find a suitable parameter that would allow me to hide it.

Quick example of the code I'm using at the moment to create my YouTube iframe:

player = new YT.Player('[PLAYER ID]', {
  height: '300',
  width: '480',
  videoId: '[VIDEO ID]',
  playerVars: { 'controls': 0, 'showinfo': 0 },
});

It's all working great so far, it's loading the video fine without controls or the info strip and I'm 'manually' playing the video using javascript.

The problem is that there's now no need for the big red 'play' button that is momentarily displayed as the video's starting.

Is there any way I can get rid of this? I've looked through the documentation and can't find a suitable parameter that would allow me to hide it.

Share Improve this question edited Dec 15, 2013 at 18:34 m59 43.8k14 gold badges121 silver badges139 bronze badges asked Dec 15, 2013 at 16:05 user1017882user1017882
Add a ment  | 

2 Answers 2

Reset to default 4

I found it not possible. So the only way to hide Play button is to place video image above the video which can be fetched from youtube as follow. Each YouTube video has 4 generated images. They are predictably formatted as follows:

http://img.youtube./vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube./vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube./vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube./vi/<insert-youtube-video-id-here>/3.jpg

But once you add the overlay, clicking on the screen instead of control will not play the video, To do this add the following jQuery which plays the video

jQuery('#overlay').click(function(){
  jQuery(this).hide();
  jQuery('#youtube_id').get(0).playVideo();
});

Each YouTube video has 4 generated images. They are predictably formatted as follows:

http://img.youtube./vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube./vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube./vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube./vi/<insert-youtube-video-id-here>/3.jpg

The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

http://img.youtube./vi/<insert-youtube-video-id-here>/default.jpg

For the high quality version of the thumbnail use a url similar to this:

http://img.youtube./vi/<insert-youtube-video-id-here>/hqdefault.jpg

There is also a medium quality version of the thumbnail, using a url similar to the HQ:

http://img.youtube./vi/<insert-youtube-video-id-here>/mqdefault.jpg

For the standard definition version of the thumbnail, use a url similar to this:

http://img.youtube./vi/<insert-youtube-video-id-here>/sddefault.jpg

For the maximum resolution version of the thumbnail use a url similar to this:

http://img.youtube./vi/<insert-youtube-video-id-here>/maxresdefault.jpg

All of the above urls are available over https too. Just change http to https in any of the above urls. Additionally, the slightly shorter hostname i3.ytimg. works in place of img.youtube. in the example urls above.

Alternatively, you can use the YouTube Data API (v3) or the older YouTube API v2.0 to get thumbnail images.

发布评论

评论列表(0)

  1. 暂无评论