Last active
February 8, 2017 07:41
-
-
Save herdianf/ff051bc4013493a284d6095c90b4e682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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