72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
// _____________________________
|
|
// Cross-Browser-Declarations.js
|
|
|
|
// WebAudio API representer
|
|
var AudioContext = window.AudioContext;
|
|
|
|
if (typeof AudioContext === 'undefined') {
|
|
if (typeof webkitAudioContext !== 'undefined') {
|
|
/*global AudioContext:true */
|
|
AudioContext = webkitAudioContext;
|
|
}
|
|
|
|
if (typeof mozAudioContext !== 'undefined') {
|
|
/*global AudioContext:true */
|
|
AudioContext = mozAudioContext;
|
|
}
|
|
}
|
|
|
|
/*jshint -W079 */
|
|
var URL = window.URL;
|
|
|
|
if (typeof URL === 'undefined' && typeof webkitURL !== 'undefined') {
|
|
/*global URL:true */
|
|
URL = webkitURL;
|
|
}
|
|
|
|
if (typeof navigator !== 'undefined' && typeof navigator.getUserMedia === 'undefined') { // maybe window.navigator?
|
|
if (typeof navigator.webkitGetUserMedia !== 'undefined') {
|
|
navigator.getUserMedia = navigator.webkitGetUserMedia;
|
|
}
|
|
|
|
if (typeof navigator.mozGetUserMedia !== 'undefined') {
|
|
navigator.getUserMedia = navigator.mozGetUserMedia;
|
|
}
|
|
}
|
|
|
|
var MediaStream = window.MediaStream;
|
|
|
|
if (typeof MediaStream === 'undefined' && typeof webkitMediaStream !== 'undefined') {
|
|
MediaStream = webkitMediaStream;
|
|
}
|
|
|
|
/*global MediaStream:true */
|
|
if (typeof MediaStream !== 'undefined') {
|
|
// override "stop" method for all browsers
|
|
if (typeof MediaStream.prototype.stop === 'undefined') {
|
|
MediaStream.prototype.stop = function() {
|
|
this.getTracks().forEach(function(track) {
|
|
track.stop();
|
|
});
|
|
};
|
|
}
|
|
}
|
|
|
|
var Storage = {};
|
|
|
|
if (typeof AudioContext !== 'undefined') {
|
|
Storage.AudioContext = AudioContext;
|
|
} else if (typeof webkitAudioContext !== 'undefined') {
|
|
Storage.AudioContext = webkitAudioContext;
|
|
}
|
|
|
|
function setSrcObject(stream, element) {
|
|
if ('srcObject' in element) {
|
|
element.srcObject = stream;
|
|
} else if ('mozSrcObject' in element) {
|
|
element.mozSrcObject = stream;
|
|
} else {
|
|
element.srcObject = stream;
|
|
}
|
|
}
|