How to play/start youtube video after clicking on an image?

后端 未结 5 1441
旧巷少年郎
旧巷少年郎 2020-12-30 03:02

I have an image and I want to start a youtube video only after I click the image. How can I do this?

Thanks a lot!

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 03:54

    Have a look at:

    Youtube API examples

    the code will be something like this:

    function onPlayerReady(event) {
        $('img').click(function() { 
            ytPlayer.playVideo();
        });
    }
    

提交回复
热议问题