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 embedded:

<script type="text/javascript">
  window.addEventListener('deviceorientation', function(orientation) {
    var playerFrame = document.getElementsByTagName('iframe')[0];
    if (playerFrame) {
      playerFrame.contentWindow.postMessage({
        alpha: orientation.alpha,
        beta: orientation.beta,
        gamma: orientation.gamma
      }, '*');
    }
  });
  window.addEventListener('orientationchange', function () {
    var playerFrame = document.getElementsByTagName('iframe')[0];
    if (playerFrame) {
      var orientation = screen.orientation || screen.mozOrientation || screen.msOrientation || {};
      playerFrame.contentWindow.postMessage({
        screenOrientation: {
          type: orientation.type || orientation,
          angle: orientation.angle
        },
        orientation: window.orientation
      }, '*');
    }
  });
</script>
Simple Share Buttons