Skip to content

Instantly share code, notes, and snippets.

@herdianf
Last active February 8, 2017 07:41
Show Gist options
  • Save herdianf/ff051bc4013493a284d6095c90b4e682 to your computer and use it in GitHub Desktop.
Save herdianf/ff051bc4013493a284d6095c90b4e682 to your computer and use it in GitHub Desktop.
var addEvent(elem, event, fn) {
if (elem.addEventListener) {
elem.addEventListener(event, fn, false);
} else {
elem.attachEvent("on" + event, function() {
return (fn.call(elem, window.event));
});
}
},
urlparser = document.createElement('a'),
iframe = null; //ambil iframes skrin
addEvent(window, 'message', function(ev) {
urlparser.href = ev.origin
var originHost = urlparser.hostname.toLowerCase()
if ( originHost !== 'skrin.id' ) return; //bye2
if ( event.data === 'ready' ) {
//player udah ready
//play
iframe.contentWindow.postMessage('play', '*')
//pause
iframe.contentWindow.postMessage('pause', '*')
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment