fixed safari support

This commit is contained in:
Sean 2018-02-13 10:46:13 -07:00
parent 05a3571ede
commit 0f5bcc71ef
4 changed files with 20 additions and 8 deletions

7
fta.js
View File

@ -233,10 +233,13 @@ var FTAPlayer = (function () {
FTAPlayer.prototype.play = function () { FTAPlayer.prototype.play = function () {
var _this = this; var _this = this;
try { try {
this.ctx = new AudioContext(); this.ctx = new (window.AudioContext || window.webkitAudioContext)();
if (this.ctx == undefined) {
throw new Error("No audio support!");
}
} }
catch (e) { catch (e) {
alert('No audio support'); alert(e.message);
return; return;
} }
this.audioNode = this.ctx.createScriptProcessor(0, 0, 2); this.audioNode = this.ctx.createScriptProcessor(0, 0, 2);

View File

@ -250,10 +250,13 @@ var Player = (function () {
Player.prototype.play = function () { Player.prototype.play = function () {
var _this = this; var _this = this;
try { try {
this.ctx = new AudioContext(); this.ctx = new (window.AudioContext || window.webkitAudioContext)();
if (this.ctx == undefined) {
throw new Error("No audio support!");
}
} }
catch (e) { catch (e) {
alert('No audio support'); alert(e.message);
return; return;
} }
this.audioNode = this.ctx.createScriptProcessor(0, 0, 2); this.audioNode = this.ctx.createScriptProcessor(0, 0, 2);

View File

@ -68,9 +68,12 @@ class FTAPlayer {
public play(): void { public play(): void {
try { try {
this.ctx = new AudioContext(); this.ctx = new ((<any>window).AudioContext || (<any>window).webkitAudioContext)();
if (this.ctx == undefined) {
throw new Error("No audio support!");
}
} catch (e) { } catch (e) {
alert('No audio support'); alert(e.message);
return; return;
} }
this.audioNode = this.ctx.createScriptProcessor(0, 0, 2); this.audioNode = this.ctx.createScriptProcessor(0, 0, 2);

View File

@ -85,9 +85,12 @@ class Player {
public play(): void { public play(): void {
try { try {
this.ctx = new AudioContext(); this.ctx = new ((<any>window).AudioContext || (<any>window).webkitAudioContext)();
if (this.ctx == undefined) {
throw new Error("No audio support!");
}
} catch (e) { } catch (e) {
alert('No audio support'); alert(e.message);
return; return;
} }
this.audioNode = this.ctx.createScriptProcessor(0, 0, 2); this.audioNode = this.ctx.createScriptProcessor(0, 0, 2);