Commit 78e79901 authored by marioromera's avatar marioromera
Browse files

try capturing events

parent c808c315
......@@ -13,16 +13,6 @@
soundManager.setup({
url: './swf/',
debugMode: true,
onready: function () {
var yourTurn = soundManager.createSound({
id: 'yourTurn',
url: './yourTurn.mp3'
});
mySound.play();
},
ontimeout: function () {
// Hrmm, SM2 could not start. Missing SWF? Flash blocked? Show an error, etc.?
}
});
</script>
</head>
......
......@@ -31,6 +31,7 @@ export default function Drawing(svgId) {
this.myTurn = false;
this.$myTurn = new Subject();
this.myTurnG;
this.yourTurnAudio;
this.myTurnLine = this.line = d3
.line()
.curve(d3.curveStepBefore)
......@@ -78,16 +79,10 @@ export default function Drawing(svgId) {
const letterCoords = myTurnPathsData.map((point) =>
point.map((p) => ({ x: p[0], y: p[1] }))
);
let yourTurnAudio;
if (myTurn) {
// AUDIO
var e = new Event('touchstart');
document.body.dispatchEvent(e);
e.preventDefault();
yourTurnAudio = soundManager.createSound({
url: './yourTurn.mp3',
});
yourTurnAudio.play({ loops: 3 });
soundManager.setVolume('yourTurnAudio', 50);
letterCoords.forEach((letter) => {
const bg = this.myTurnG
......@@ -110,7 +105,7 @@ export default function Drawing(svgId) {
} else {
console.log('Finishing turn');
soundManager.stopAll();
soundManager.setVolume('yourTurnAudio', 0);
this.myTurnG.selectAll('path').remove();
}
});
......@@ -156,10 +151,7 @@ export default function Drawing(svgId) {
this.listen = (event) => {
event.preventDefault();
let yourTurnAudio = soundManager.createSound({
url: './yourTurn.mp3',
});
yourTurnAudio.play({ loops: 3 });
if (!this.myTurn) {
console.log('Not my turn');
......
......@@ -18,6 +18,20 @@ import _ from 'lodash';
import Drawing from './components/drawing';
const draw = new Drawing('#drawing-svg');
import yourturnfile from '../assets/yourturn.ogg';
import { soundManager } from 'soundmanager2';
document.querySelector('app').addEventListener('click', playSound, false);
const yourTurnAudio = soundManager.createSound({
id: 'yourTurnAudio',
url: './yourTurn.mp3',
});
function playSound(e) {
yourTurnAudio.play({ loops: 3, volume: 0 });
}
const idContainer = document
.querySelector('.id-container')
.getBoundingClientRect().height;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment