Skip to content

Commit

Permalink
Merge pull request #1 from miukimiu/fixing-chrome-issue-audiocontext-…
Browse files Browse the repository at this point in the history
…resume

Fixing chrome issue - audioContext must be resumed
  • Loading branch information
elizabetdev authored Mar 20, 2019
2 parents cbca352 + 7134e05 commit e36e724
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 203 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"p5": "^0.7.3",
"popmotion": "^8.4.1",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-p5-wrapper": "^0.0.4",
"react-scripts": "2.0.4",
"styled-components": "^3.4.10",
"styled-normalize": "^8.0.2"
"styled-components": "^4.1.3",
"styled-normalize": "^8.0.6"
},
"scripts": {
"start": "react-scripts start",
Expand All @@ -28,8 +30,6 @@
"devDependencies": {
"inline-worker": "^1.1.0",
"lodash": "^4.17.11",
"p5": "^0.7.2",
"react-p5-wrapper": "0.0.4",
"snapsvg": "^0.5.1",
"snapsvg-cjs": "0.0.6",
"svg.js": "^2.6.6"
Expand Down
Binary file modified sketch/cassette.sketch
Binary file not shown.
7 changes: 4 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { Component } from "react";
import CassetteTape from "./components/CassetteTape";
import { injectGlobal } from "styled-components";
import { createGlobalStyle } from "styled-components";
import styledNormalize from "styled-normalize";

injectGlobal`
const GlobalStyles = createGlobalStyle`
@import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400');
${styledNormalize}
${styledNormalize};
html {
box-sizing: border-box;
Expand All @@ -27,6 +27,7 @@ class App extends Component {
render() {
return (
<div className="App">
<GlobalStyles />
<CassetteTape vizColor="#19ca90" />
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion src/components/CassetteTape.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class CassetteTape extends React.Component {
if (isRecording) {
this.stopRecording();
} else {
if (this.recorder.recorder.context.state === "suspended") {
this.recorder.recorder.context.resume();
}
this.recorder.record();
}

Expand Down Expand Up @@ -139,7 +142,7 @@ class CassetteTape extends React.Component {
}}
>
<Wrapper
innerRef={this.casseteRef}
ref={this.casseteRef}
className="cassette-wrapper"
vizColor={vizColor}
>
Expand Down
169 changes: 0 additions & 169 deletions src/components/Recorder.jsx

This file was deleted.

1 change: 1 addition & 0 deletions src/components/recorder/audio-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AudioRecorder {
};

let audioContext;

try {
// webkit shim
window.AudioContext = window.AudioContext || window.webkitAudioContext;
Expand Down
6 changes: 6 additions & 0 deletions src/components/visualization/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ export default function sketch(p) {
p.vertex(0, p.windowHeight);
p.endShape(p.CLOSE);
};

p.touchStarted = function() {
if (mic.mediaStream.context.state !== "running") {
mic.mediaStream.context.resume();
}
};
}
Loading

0 comments on commit e36e724

Please sign in to comment.