[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Mon Aug 27 2018

Why are device movements not registered if an iframe is used?

If the player is used within an iframe, the browser might block access to the required browser APIs. To work around this limitation, please add the following code (please adjust if you are using more than one iframe on the website) to the website where the iframe is embedd:

1<script type="text/javascript">
2 window.addEventListener('deviceorientation', function(orientation) {
3 var playerFrame = document.getElementsByTagName('iframe')[0];
4 if (playerFrame) {
5 playerFrame.contentWindow.postMessage({
6 alpha: orientation.alpha,
7 beta: orientation.beta,
8 gamma: orientation.gamma
9 }, '*');
10 }
11 });
12 window.addEventListener('orientationchange', function () {
13 var playerFrame = document.getElementsByTagName('iframe')[0];
14 if (playerFrame) {
15 var orientation = screen.orientation || screen.mozOrientation || screen.msOrientation || {};
16 playerFrame.contentWindow.postMessage({
17 screenOrientation: {
18 type: orientation.type || orientation,
19 angle: orientation.angle
20 },
21 orientation: window.orientation
22 }, '*');
23 }
24 });
25</script>

Give us feedback