1
votes

When I stopped youtube video by calling stopVideo() function using youtube API, It stopped video and moved video to first time frame. But I wanted to show thumbnail image which shows at the first time of the video loading before first start. (In other words - preview image?)

I know a way to do this - removing iframe and reloading again with API. (using YT.player)

But I don't think it's good way as every time I build iframe It throws an error :

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://dev.com').

Does someone know how to show thumbnail image at the stopping youtube video with API?

Or any way to fix the above error?

1

1 Answers

1
votes

Instead of using the stopVideo() function, use the cueVideoById(videoId) function. Just pass in the same videoId and it will load up the same video in a stopped state with thumbnail and play button:

https://developers.google.com/youtube/js_api_reference#cueVideoById