slot2/js/slot.js
function initAudio( audios, callback ) {

    var format = 'mp3';
    var elem = document.createElement('audio');
    if ( elem ) {
        // Check if we can play mp3, if not then fall back to ogg
        if( !elem.canPlayType( 'audio/mpeg;' ) && elem.canPlayType('audio/ogg;')) format = 'ogg';
    }

    var AudioContext = window.webkitAudioContext || window.mozAudioContext || window.MSAudioContext || window.AudioContext;

    if ( AudioContext ) {
        $('#audio_debug').text('WebAudio Supported');
        // Browser supports webaudio
        // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
        return _initWebAudio( AudioContext, format, audios, callback );
    } else if ( elem ) {
        $('#audio_debug').text('HTML5 Audio Supported');
        // HTML5 Audio
        // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#the-audio-element
        return _initHTML5Audio(format, audios, callback);
    } else {
        $('#audio_debug').text('Audio NOT Supported');
        // audio not supported
        audios.forEach(function(item) {
            item.play = function() {}; // dummy play
        });
        callback();
    }
}
function initAudio( audios, callback ) {

    var format = 'mp3';
    var elem = document.createElement('audio');
    if ( elem ) {
        // Check if we can play mp3, if not then fall back to ogg
        if( !elem.canPlayType( 'audio/mpeg;' ) && elem.canPlayType('audio/ogg;')) format = 'ogg';
    }

    var AudioContext = window.webkitAudioContext || window.mozAudioContext || window.MSAudioContext || window.AudioContext;

    if ( AudioContext ) {
        $('#audio_debug').text('WebAudio Supported');
        // Browser supports webaudio
        // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
        return _initWebAudio( AudioContext, format, audios, callback );
    } else if ( elem ) {
        $('#audio_debug').text('HTML5 Audio Supported');
        // HTML5 Audio
        // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#the-audio-element
        return _initHTML5Audio(format, audios, callback);
    } else {
        $('#audio_debug').text('Audio NOT Supported');
        // audio not supported
        audios.forEach(function(item) {
            item.play = function() {}; // dummy play
        });
        callback();
    }
}
function initAudio ( audios , callback ) { var format = 'mp3' ; var elem = document . createElement ( 'audio' ) ; if ( elem ) { // Check if we can play mp3, if not then fall back to ogg if ( ! elem . canPlayType ( 'audio/mpeg;' ) && elem . canPlayType ( 'audio/ogg;' ) ) format = 'ogg' ; } var AudioContext = window . webkitAudioContext || window . mozAudioContext || window . MSAudioContext || window . AudioContext ; if ( AudioContext ) { $ ( '#audio_debug' ) . text ( 'WebAudio Supported' ) ; // Browser supports webaudio // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html return _initWebAudio ( AudioContext , format , audios , callback ) ; } else if ( elem ) { $ ( '#audio_debug' ) . text ( 'HTML5 Audio Supported' ) ; // HTML5 Audio // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#the-audio-element return _initHTML5Audio ( format , audios , callback ) ; } else { $ ( '#audio_debug' ) . text ( 'Audio NOT Supported' ) ; // audio not supported audios . forEach ( function ( item ) { item . play = function ( ) { } ; // dummy play } ) ; callback ( ) ; } }
Initializes audio and loads audio files
Initializes audio and loads audio files