diff --git a/src/api/player.js b/src/api/player.js index e4176c2a..fcbe9763 100644 --- a/src/api/player.js +++ b/src/api/player.js @@ -199,6 +199,8 @@ Player.prototype.onMessage_ = function(event) { case 'click': case 'ended': case 'getposition': + case 'focus': + case 'blur': this.emit(type, data); break; case 'volumechange': diff --git a/src/embed/iframe-message-receiver.js b/src/embed/iframe-message-receiver.js index 8bcd1a8c..b8d319a8 100644 --- a/src/embed/iframe-message-receiver.js +++ b/src/embed/iframe-message-receiver.js @@ -56,6 +56,8 @@ IFrameMessageReceiver.prototype.onMessage_ = function(event) { case Message.SET_CURRENT_TIME: case Message.GET_POSITION: case Message.SET_FULLSCREEN: + case Message.FOCUS: + case Message.BLUR: this.emit(type, data); break; default: diff --git a/src/embed/main.js b/src/embed/main.js index cb32fdab..4e6e1714 100644 --- a/src/embed/main.js +++ b/src/embed/main.js @@ -53,6 +53,8 @@ worldRenderer.on('modechange', onModeChange); worldRenderer.on('ended', onEnded); worldRenderer.on('play', onPlay); worldRenderer.hotspotRenderer.on('click', onHotspotClick); +worldRenderer.hotspotRenderer.on('blur', onHotspotBlur); +worldRenderer.hotspotRenderer.on('focus', onHotspotFocus); window.worldRenderer = worldRenderer; @@ -271,6 +273,20 @@ function onHotspotClick(id) { }); } +function onHotspotBlur(id) { + Util.sendParentMessage({ + type: 'blur', + data: {id: id} + }); +} + +function onHotspotFocus(id) { + Util.sendParentMessage({ + type: 'focus', + data: {id: id} + }); +} + function onPlay() { Util.sendParentMessage({ type: 'paused', diff --git a/src/message.js b/src/message.js index f7924d40..e86be3b1 100644 --- a/src/message.js +++ b/src/message.js @@ -28,6 +28,8 @@ var Message = { DEVICE_MOTION: 'devicemotion', GET_POSITION: 'getposition', SET_FULLSCREEN: 'setfullscreen', + FOCUS: 'focus', + BLUR: 'blur' }; module.exports = Message;