996Playing/Pausing Embedded Vimeo Videos with custom JS

Embedded Vimeo in HTML Page:

<iframe id="vi" src="https://player.vimeo.com/video/123"></iframe>

Pause:

var msg = JSON.stringify({method: "pause"}

Play:

var msg = JSON.stringify({method: "play"}

jQuery:

$("#vi")[0].contentWindow.postMessage(msg, "*")

Pure JS:

document.getElementById("vi").contentWindow.postMessage(msg, "*")