-
Notifications
You must be signed in to change notification settings - Fork 159
/
iframe.html
77 lines (75 loc) · 2.47 KB
/
iframe.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>videojs-panorama in Iframe Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body{
margin: 0;
}
body.vjs-full-window .player_wrapper{
position: static!important;
}
body.vjs-full-window .player_container{
padding-top: initial!important;
}
body.vjs-full-window #player{
position: fixed!important;
}
.player_wrapper{
position: relative;
max-width: 960px;
width: 90%;
}
.player_container{
padding-top: 56.25%;
}
#player{
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
</style>
</head>
<body>
<div class="player_wrapper">
<div class="player_container">
<iframe id="player" src="iframe-video.html" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
<script>
(function () {
var player = document.getElementById("player");
var playerWidth = player.width;
var playerHeight = player.height;
window.addEventListener('devicemotion', function (event) {
var obj = {
rotationRate: {
alpha: event.rotationRate.alpha,
beta: event.rotationRate.beta,
gamma: event.rotationRate.gamma
},
portrait: window.matchMedia("(orientation: portrait)").matches,
landscape: window.matchMedia("(orientation: landscape)").matches,
orientation: window.orientation
};
player.contentWindow.postMessage({type: "device-motion", events: obj}, "*");
});
window.addEventListener("message", function (event) {
if(event.data == "enterFullWindow"){
document.getElementsByTagName("body")[0].classList.add("vjs-full-window");
player.width = window.outerWidth;
player.height = window.outerHeight;
}else if(event.data == "exitFullWindow"){
player.width = playerWidth;
player.height = playerHeight;
document.getElementsByTagName("body")[0].classList.remove("vjs-full-window");
}
}, false);
})();
</script>
</body>
</html>