Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.seek = function(t) {
if (!this.playing && t >= 0) {
// Sometimes browsers will prevent the audio from playing.
// We need to resume the AudioContext or it will never play.
if (Howler.ctx.state == "suspended") {
Howler.ctx.resume().then(() => this.howl.play());
} else {
this.howl.play();
}
this.playing = true;
}
if (this.playing) {
if (t < 0) {
this.howl.stop();
this.playing = false;
} else {
const playerPos = this.howl.seek();
if (Math.abs(playerPos - t) > kTolerance) {
this.howl.seek(t);
this.seek = function(t) {
if (!this.playing && t >= 0) {
// Sometimes browsers will prevent the audio from playing.
// We need to resume the AudioContext or it will never play.
if (Howler.ctx.state == "suspended") {
Howler.ctx.resume().then(() => this.howl.play());
} else {
this.howl.play();
}
this.playing = true;
}
if (this.playing) {
if (t < 0) {
this.howl.stop();
this.playing = false;
} else {
const playerPos = this.howl.seek();
if (Math.abs(playerPos - t) > kTolerance) {
this.howl.seek(t);
}
setup() {
const canvas = document.getElementsByTagName('canvas')[0];
this.WIDTH = canvas.width;
this.HEIGHT = canvas.height;
this.analyser = Howler.ctx.createAnalyser();
Howler.masterGain.connect(this.analyser);
this.analyser.connect(Howler.ctx.destination);
this.canvasCtx = canvas.getContext("2d");
this.analyser.fftSize = 256;
this.bufferLength = this.analyser.frequencyBinCount;
this.dataArray = new Uint8Array(this.bufferLength);
}
setup() {
const canvas = document.getElementsByTagName('canvas')[0];
this.WIDTH = canvas.width;
this.HEIGHT = canvas.height;
this.analyser = Howler.ctx.createAnalyser();
Howler.masterGain.connect(this.analyser);
this.analyser.connect(Howler.ctx.destination);
this.canvasCtx = canvas.getContext("2d");
this.analyser.fftSize = 256;
this.bufferLength = this.analyser.frequencyBinCount;
this.dataArray = new Uint8Array(this.bufferLength);
}
private createAnalyser(): void {
const analyser = Howler.ctx.createAnalyser();
Howler.masterGain.connect(analyser);
this.analyserChange.next(analyser);
}