forked from egbertbouman/billy-radio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframes.html
36 lines (30 loc) · 1.52 KB
/
frames.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html>
<iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms" id="edx" src="" scrolling="yes" marginheight="0" marginwidth="0" style="position: fixed; bottom: 0px; right: 0px; height: 100%; width: 100%; margin: 0px;"></iframe>
<iframe id="widget" src="http://egbertbouman.github.io/billy-radio/widget.html" scrolling="no" marginheight="0" marginwidth="0" style="position: fixed; bottom: 10px; right: 10px; z-index: 999; height: 100px; width: 370px; border: none;"></iframe>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
<script type="text/javascript">
var edx = document.getElementById('edx');
edx.src = document.referrer;
edx.onload = function() {
console.log('edX iframe loaded');
$('.hide-if-widget-shown', $('#edx').contents()).hide();
$('#edx')[0].contentWindow.$('.video').on('play', function(){
console.log('edx video playing');
$('#widget')[0].contentWindow.postMessage('mute-volume', '*');
});
$('#edx')[0].contentWindow.$('.video').on('pause ended', function(){
console.log('edX video stopped');
$('#widget')[0].contentWindow.postMessage('restore-volume', '*');
});
}
$('#widget').load(function() {
console.log('Widget iframe loaded');
});
window.onmessage = function(event) {
if (event.data === 'close-widget') {
window.location = $('#edx').contents().get(0).location.href;
}
};
</script>
</html>