ai-tube / public /aframe /play-on-click.js
jbilcke's picture
add VR video viewer
2156c54
raw
history blame contribute delete
475 Bytes
/* global AFRAME */
AFRAME.registerComponent('play-on-click', {
init: function () {
this.onClick = this.onClick.bind(this);
},
play: function () {
window.addEventListener('click', this.onClick);
},
pause: function () {
window.removeEventListener('click', this.onClick);
},
onClick: function (evt) {
var videoEl = this.el.getAttribute('material').src;
if (!videoEl) { return; }
this.el.object3D.visible = true;
videoEl.play();
}
});