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

javascript - Using PLYR for Youtube videos - poster image? - Stack Overflow

programmeradmin3浏览0评论

I am using Plyr () to play Youtube videos inline. But i now want to add a poster to the player, so i can use a thumbnail for the video, before it plays.

Plyr supports this, but i can not get it to work. I am currently using Plyr in its most simple form:

Youtube video: <div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>

Initialize Plyr: <script>plyr.setup();</script>

Thats it. How can i get the above snippet to show a poster for "/myposter.png"?

I am using Plyr (https://github./sampotts/plyr) to play Youtube videos inline. But i now want to add a poster to the player, so i can use a thumbnail for the video, before it plays.

Plyr supports this, but i can not get it to work. I am currently using Plyr in its most simple form:

Youtube video: <div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>

Initialize Plyr: <script>plyr.setup();</script>

Thats it. How can i get the above snippet to show a poster for "/myposter.png"?

Share Improve this question edited Feb 2, 2018 at 9:08 beaver 17.7k2 gold badges43 silver badges68 bronze badges asked May 22, 2017 at 14:17 brotherbrother 8,1819 gold badges39 silver badges62 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Here is some example to achieve youtube video custom cover image:

player.poster = '../Images/landing/attendance/Admin Back.png';

example

or

var player = new Plyr('#vid'); setTimeout(() => { player.poster = 'http://ichef.bbci.co.uk/images/ic/640x360/p03hj5f7.jpg'; }, 500)

or

you can read this article A Better Method for Embedding YouTube Videos on your Website

Just use the poster attribute on html5 video tag:

<video poster="/myposter.png" controls>

check out at https://github./sampotts/plyr#html

发布评论

评论列表(0)

  1. 暂无评论