startMobile on all of the examples

Fixes #13
This commit is contained in:
Yotam Mann 2014-09-05 01:13:39 -04:00
parent 62568bd4ac
commit 3aa76d19c8
15 changed files with 39 additions and 17 deletions

View file

@ -22,6 +22,29 @@ GUI.StartButton.prototype.buttonClicked = function(){
this.callback();
};
/**
* a start button for mobile browsers which require a touchstart event
* to start the audio
*/
GUI.MobileStart = function(callback){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
this.element = $("<div>", {"class" : "StartButton"})
.appendTo("#Container");
this.button = $("<button>")
.button({label: "\u25B6"})
.click(this.buttonClicked.bind(this))
.appendTo(this.element);
this.callback = callback;
}
};
GUI.MobileStart.prototype.buttonClicked = function(){
this.element.fadeTo(500, 0, function(){
$(this).remove();
});
this.callback();
};
/**
* Tone.Envelope GUI
* @param {jQuery} container the jQuery object to put the gui in

View file

@ -48,16 +48,14 @@
// GUI //
new GUI.TopBar(Tone);
new GUI.StartButton(function(){
Tone.startMobile();
panner.start();
});
new GUI.MobileStart(Tone.startMobile);
var container = $("#Content");
new GUI.Checkbox(container, function(on){
if (on){
sine.start();
panner.start();
} else {
sine.stop();
}

View file

@ -62,7 +62,7 @@
// GUI //
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
var content = $("#Content");

View file

@ -61,7 +61,7 @@
// GUI //
new GUI.TopBar(Tone);
// new GUI.StartButton(Tone.startMobile);
// new GUI.MobileStart(Tone.startMobile);
$("#tabs").tabs();

View file

@ -48,7 +48,7 @@
$(function(){
var container = $("#Content");
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
//sliders for the envelope controls

View file

@ -62,7 +62,7 @@
// GUI //
new GUI.TopBar(Tone);
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
$("#tabs").tabs();

View file

@ -50,7 +50,7 @@
var content = $("#Content");
new GUI.TopBar(Tone);
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.Checkbox(content, function(on){
if (on){

View file

@ -59,7 +59,7 @@
// GUI //
new GUI.TopBar(Tone);
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
$("#tabs").tabs();

View file

@ -30,6 +30,7 @@
/* globals Tone, GUI */
var noise = new Tone.Noise();
noise.setVolume(-10);
noise.toMaster();
var noiseTypes = ["white", "brown", "pink"];
@ -54,7 +55,7 @@
// GUI //
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
new GUI.Momentary($("#Button"), function(){

View file

@ -43,7 +43,7 @@
$(function(){
var content = $("#Content");
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
new GUI.Checkbox(content, function(on){
if (on){

View file

@ -42,7 +42,7 @@
// GUI //
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
new GUI.Momentary($("#Content"), function(on){

View file

@ -41,7 +41,7 @@
// GUI //
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
new GUI.Momentary($("#Content"), function(on){

View file

@ -98,7 +98,7 @@
// GUI //
var content = $("#Content");
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
//the transport controls

View file

@ -76,7 +76,7 @@
// GUI //
new GUI.TopBar(Tone);
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
var container = $("#Content");

View file

@ -96,7 +96,7 @@
}
}
new GUI.StartButton(Tone.startMobile);
new GUI.MobileStart(Tone.startMobile);
new GUI.TopBar(Tone);
var startButton = $("#StartButton");