I am playing around with Leap Motion's JS SDK. Whichever example I see on the internet it does run fine even when the browser window is in background = the example get updated on every frame. However, I cannot figure out what to do to actually achieve the same thing, my examples always stop when the browser window loses focus. Let's take this very small example:
<body>
<p style="margin-left: 100px" id="info"></p>
<script>
var info = document.getElementById('info');
var controller = new Leap.Controller({
host: '127.0.0.1',
port: 6437,
enableGestures: true,
frameEventName: 'animationFrame',
useAllPlugins: true
});
controller.connect();
controller.setBackground(true);
controller.on('frame', onFrame);
function onFrame(frame) {
info.innerHTML = frame.id;
}
</script>
</body>
Controller.setBackground() says: Informs the Leap Motion WebSocket server that your application always wants to receive frames of tracking data when it is in the background and not being actively used. Note that setting this option true could lead to unintended input to your application while the user interacts with other applications. Most applications should not receive frames in the background.
Kind of doesn't work to me, what am I doing wrong? Thanks a lot!