Skip to content

Commit

Permalink
Fixes Okazari#7: Not working on Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
ldd committed Sep 5, 2017
1 parent e1c7d75 commit d347eaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions rythm.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var Analyser = function Analyser() {

var Analyser$1 = new Analyser();

var Player = function Player() {
var Player = function Player(forceAudioContext) {
var _this = this;

classCallCheck(this, Player);
Expand All @@ -109,7 +109,6 @@ var Player = function Player() {
_this.source = _this.createSourceFromAudioElement(_this.audio);
} else {
_this.source = _this.connectedSources[connectedIndex];
console.log(_this.source);
}
_this.connectSource(_this.source);
};
Expand Down Expand Up @@ -168,8 +167,8 @@ var Player = function Player() {
}
};

this.browserAudioCtx = AudioContext || webkitAudioContext;
this.audioCtx = new this.browserAudioCtx();
this.browserAudioCtx = window.AudioContext || window.webkitAudioContext;
this.audioCtx = forceAudioContext || new this.browserAudioCtx();
this.connectedSources = [];
Analyser$1.initialise(this.audioCtx.createAnalyser());
this.gain = this.audioCtx.createGain();
Expand All @@ -183,8 +182,6 @@ var Player = function Player() {
};
};

var player = new Player();

var pulse = (function (elem, value) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

Expand Down Expand Up @@ -290,7 +287,7 @@ var Dancer = function () {

var dancer = new Dancer();

var Rythm$1 = function Rythm() {
var Rythm$1 = function Rythm(forceAudioContext) {
var _this = this;

classCallCheck(this, Rythm);
Expand All @@ -311,6 +308,10 @@ var Rythm$1 = function Rythm() {
return _this.player.setGain(value);
};

this.connectSource = function (source) {
return _this.player.connectSource(source);
};

this.addRythm = function (elementClass, type, startValue, nbValue, options) {
_this.rythms.push({
elementClass: elementClass,
Expand Down Expand Up @@ -348,7 +349,7 @@ var Rythm$1 = function Rythm() {
_this.player.stop();
};

this.player = player;
this.player = new Player(forceAudioContext);
this.analyser = Analyser$1;
this.maxValueHistory = Analyser$1.maxValueHistory;
this.dancer = dancer;
Expand Down
2 changes: 1 addition & 1 deletion src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Analyser from './Analyser.js'

class Player {
constructor(forceAudioContext) {
this.browserAudioCtx = AudioContext || webkitAudioContext
this.browserAudioCtx = window.AudioContext || window.webkitAudioContext
this.audioCtx = forceAudioContext || new this.browserAudioCtx()
this.connectedSources = []
Analyser.initialise(this.audioCtx.createAnalyser())
Expand Down

0 comments on commit d347eaa

Please sign in to comment.