JavaScript playback with integrated Instagram video

So, I managed to embed Instagram videos on my site. I would like to play them using my own button and Javascript function. Is it possible?

I have included my sample code below, which works for YouTube and Vimeo, but not for Instagram.

<script language="javascript"> function playVideo(videoType) { var iframe = document.getElementById('video'); if(videoType== "youtube") iframe.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); else if(videoType == "vimeo") iframe.contentWindow.postMessage('{"method":"play"}', '*'); else if(videoType == "instagram") alert("Don't know how to play instagram videos"); } </script> <a onclick="playVideo('instagram')">PLAY</a> <br/> <iframe id="video" src="https://instagram.com/p/vNquyLpjaZ/embed/" width=240 height=312 /> 
+5
source share

Source: https://habr.com/ru/post/1206620/


All Articles