Commit a52e9e63 authored by marioromera's avatar marioromera
Browse files

add sound to your turn! yeah

parent 63f8038e
......@@ -4,6 +4,9 @@ import { updateGossipData } from '../scuttlebutt';
import { state } from '../state';
import { Subject } from 'rxjs';
import { myTurnPathsData } from './myTurnPathData';
import yourturnfile from '../../assets/yourturn.ogg';
var yourTurnAudio = new Audio(yourturnfile);
yourTurnAudio.loop = true;
const MARGIN = 20;
const createEmptySession = () => ({
......@@ -23,6 +26,7 @@ export default function Drawing(svgId) {
this.color;
this.point;
this.pointInterval;
this.turnInterval;
this.path;
this.drawing = false;
this.zoom;
......@@ -76,7 +80,14 @@ export default function Drawing(svgId) {
const letterCoords = myTurnPathsData.map((point) =>
point.map((p) => ({ x: p[0], y: p[1] }))
);
if (myTurn) {
// AUDIO
let duration = Math.round(yourTurnAudio.duration * 1000);
console.log('DURATION ', duration);
yourTurnAudio.play();
letterCoords.forEach((letter) => {
const bg = this.myTurnG
.append('path')
......@@ -96,6 +107,9 @@ export default function Drawing(svgId) {
.attr('fill', 'transparent');
});
} else {
console.log('Finishing turn');
yourTurnAudio.pause();
this.myTurnG.selectAll('path').remove();
}
});
......@@ -180,7 +194,7 @@ export default function Drawing(svgId) {
if (!this.drawing) return;
this.drawing = false;
clearInterval(this.pointInterval);
this.$myTurn.next(false);
// add newly created line to the drawing sessions
updateGossipData('sessions', [...state.data.sessions, this.session]);
......
......@@ -31,6 +31,10 @@ module.exports = {
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000',
},
{
test: /\.(ogg|mp3|wav|mpe?g)$/i,
loader: 'file-loader',
},
{
test: /\.(sa|sc|c)ss$/,
use: [
......
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