jsbasic/bell.js

42 lines
9.9 KiB
JavaScript
Raw Normal View History

//
// Bell - play an audio file for the CHR$(7) "BEL" beep
//
var Bell;
if (typeof Bell !== 'function') {
Bell = function(base) {
2013-08-18 05:40:29 +00:00
var DATA_MP3 = "data:audio/mp3;base64,//tQxAAACKhXabQTABGrmzE3KVACUZAAJACBEnA2wABBGMYxuAF3d33u4iIgghlkCBAAECCByJwfl4nB8P/B8HwfxOD4PrP8Hz/ggCAIA+fKAg7/+IAxlDmIOBwOBwOBwOBwOBgAAAAvsPfh+QCdNGoDlrCk09ENDCfgEgcONDUH+Bg80gbDCIBANAwwBWK2cNMQQC9wNjQYRAKDP/gGA4ZUUqKXC+Yj5vv8LLgsaAzgLgMCgQMgCwk1m/5p5fJ9S3PKI46qbzQCZASIFv6LvP/7UsQFAAupY3W89oARPSludJapcmndwY1sa2ew6Yta/COmtiB/qdMDuEhHiXUNfk5v+sWItkv//9RkF7Rb/1N61Lvd67JIcxJUFILyVf//sp6W691nbOozm3f00mPKFeZqYAC5BEMl25UAwQEyBZsBRtaDKwmBWpxRAT7sZUPnBK/+tEGwGtqFu8mGrHG/wZDv///qAZ/+PTG9UfI0f/uCbf//7onfzWW2eSw21qxBNPwNvYI70upORAMFBMg27hCQ55uY0DYA8ANOsP/9BJNf//tSxAyACjmHdaQ0VdFuMm41BQ+bVdUFuDgSW/o5PPer4ukf///zgRLf/nkG1roKOTX/oJgqTe3//9907V00j0+tgQzLWrU3msKrzlowStENECIgObmyJSNnOomSK5FQ2g85q6XacHT/1mQJYXDjoIiVi6fMkudf/xWSt///3UA5f/nGIW+ui3/zACX///+5dPM79c7aI8r6DMCiMXFnW1NF51RfwVEU/OqTJgQICRATfggIh5hy2/QUfA5rUHb50Ks//RBuBIhMVItWtJpqU1//+1LEE4BKuUt3pg2kUTUsbvDYD5pL4aTbW3//8TH/8xM/7V0n/qwBdY0r/7L33SqrZXvTsqaF8GBz3gAI6WOPu3NSaUzIABBUFaaJqYEo6NUfgs0v/Fr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pqrasmmqtmyqqm27quz6sm3rummqsm2qpi2bqmrbruzqsizbui9pmmlqnmeamueZpmmasmyaqitbnqeaniiqquaJpmqqqiybpqrKlueZqieKquqJnmuaqirLpmraqmmatmyqqi2bpirLrm37vuvKsm6qqmybqmrrpmrKsmzLvu/Kqu6KpinLpqrasmmqsi3bsu/Lsqz7omnKsmmqsm2qqi7Lsm0bs2z7umiasm2qpi2bqirbsi37uizbuu/Krm+rqqzrsi37uu76rnDrujC8smz7qqz6uivbum/rMtv2fUTTlGVTNW3bVFVZdmXZ9mXb9n3RNG1bVVVbNk3VtmVZ9n1Ztm1hNE3ZNlVV1k3VtG1Zlm1htmXhdmXZt2Vb9nXXlXVf133j12Xd5rqy7cuyrfuqq/q27vvCcOuu8AoAABhwAAAIMKEMFBqyEgCIAgAAjGGMMQiNUs45B6FRyjnnIGTOQQghlcw5CCGUkjkHoZSUMucglJJSCKGUlFoLIZSUUmsFAAAUOAAABNigKbE4QKEhKwGAVAAAg+NYlueZomrasmNJnieKqqmqtu1IlueJommqqm1bnieKpqmqruvrmueJommqquvqumiapqmqruu6ui6aoqmqquu6sq6bpqqqriu7suzrpqqqquvKriz7wqq6rivLsm3rwrCqruvKsmzbtm/cuq7rvu/7wpGt67ou/MIxDEcBAOAJDgBABTasjnBSNBZYaMhKACADAIAwBiGDEEIGIYSQUkohpZQSAAAw4AAAEGBCGSg0ZEUAECcAABhDKaSUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJIKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKqaSUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKZVSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSS
var tag;
// Prefer HTML5 audio
tag = document.createElement('audio');
if (typeof tag.canPlayType === 'function') {
tag.setAttribute('preload', 'true');
2013-08-18 05:40:29 +00:00
if (tag.canPlayType('audio/mp3') || tag.canPlayType('audio/mpeg')) {
tag.setAttribute('src', DATA_MP3);
} else if (tag.canPlayType('audio/ogg')) {
2013-08-18 05:40:29 +00:00
tag.setAttribute('src', DATA_OGG);
}
this.play = function() { tag.play(); };
this.stop = function() { tag.pause(); tag.currentTime = 0; };
return;
}
// Fallback for IE<9
tag = document.createElement('bgsound');
if ('loop' in tag) {
tag.src = base + 'bell.wav';
tag.loop = 1;
this.play = function() { document.body.appendChild(tag); };
this.stop = function() { document.body.removeChild(tag); };
return;
}
this.play = function() { };
this.stop = function() { };
};
}