7

So I've managed to embed Instagram videos in my website. I would like to play them using my own button and a Javascript function. Is this possible?

I have included my example 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 />
4

0 回答 0