Permalink
Browse files

added function for testing browser support

  • Loading branch information...
1 parent 3de81fd commit dcfe004d607023c622b3c38f8277a24cd4cddd38 @sebpiq committed Oct 2, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/main.js
View
@@ -35,6 +35,20 @@
Pd.arraySlice = function (array, start) { return array.subarray(start) };
}
+ // Returns true if the current browser supports WebPd, false otherwise.
+ Pd.isSupported = function() {
+ // Web audio API - Chrome, Safari
+ var test = typeof window === 'undefined' ? null : window.webkitAudioContext || window.AudioContext;
+ if (test) return true;
+
+ // Audio data API - Firefox
+ var audioDevice = new Audio();
+ if (audioDevice.mozSetup) return true;
+
+ // All the rest
+ return false;
+ }
+
// every new patch registers itself using this function
Pd.register = function(patch) {
if (this._patches.indexOf(patch) == -1) {

0 comments on commit dcfe004

Please sign in to comment.