hook up pause menu actions (resume, restart, exit), but still need to force beats to reposition off audio.currentTime
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* Pause all beats.
|
||||
*/
|
||||
AFRAME.registerComponent('beat-pauser', {
|
||||
pause: function () {
|
||||
for (let i = 0; i < this.el.children.length; i++) {
|
||||
this.el.children[i].pause();
|
||||
}
|
||||
},
|
||||
|
||||
play: function () {
|
||||
for (let i = 0; i < this.el.children.length; i++) {
|
||||
this.el.children[i].play();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
AFRAME.registerComponent('saber-controls', {
|
||||
schema: {
|
||||
bladeEnabled: {default: false},
|
||||
hand: {default: 'right', oneOf: ['left', 'right']}
|
||||
hand: {default: 'right', oneOf: ['left', 'right']},
|
||||
isPaused: {default: false}
|
||||
},
|
||||
|
||||
init: function () {
|
||||
@@ -24,6 +25,9 @@ AFRAME.registerComponent('saber-controls', {
|
||||
update: function (oldData) {
|
||||
if (!oldData.bladeEnabled && this.data.bladeEnabled) {
|
||||
this.bladeEl.emit('drawblade');
|
||||
if (!oldData.isPaused) {
|
||||
this.bladeEl.emit('drawbladesound');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -12,10 +12,17 @@ AFRAME.registerComponent('song', {
|
||||
|
||||
init: function () {
|
||||
// Use audio element for audioanalyser.
|
||||
this.audio = document.createElement('audio');
|
||||
this.audio.setAttribute('id', 'song');
|
||||
this.audio.crossOrigin = 'anonymous';
|
||||
this.el.sceneEl.appendChild(this.audio);
|
||||
const audio = this.audio = document.createElement('audio');
|
||||
audio.setAttribute('id', 'song');
|
||||
audio.crossOrigin = 'anonymous';
|
||||
this.el.sceneEl.appendChild(audio);
|
||||
|
||||
this.el.addEventListener('pausemenurestart', () => {
|
||||
if (audio.paused) {
|
||||
audio.currentTime = 0;
|
||||
audio.play();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
update: function (oldData) {
|
||||
|
||||
Reference in New Issue
Block a user