var Browser = require('./Browser'); var Audio = { audioData: false , dolby: false , m4a: false , mp3: false , ogg: false , opus: false , wav: false , webAudio: false , webm: false } ; function init(){ Audio.audioData = !!(window.Audio); Audio.webAudio = !!(window.AudioContext || window.webkitAudioContext); var audioElement = _AN_Call_createelement('createElement', document, 'audio'); var result = !!audioElement.canPlayType; try { if (result) { if (_AN_Call_replace('replace', audioElement.canPlayType('audio/ogg; codecs="vorbis"'), /^no$/, '')) { Audio.ogg = true ; } if (_AN_Call_replace('replace', audioElement.canPlayType('audio/ogg; codecs="opus"'), /^no$/, '') || _AN_Call_replace('replace', audioElement.canPlayType('audio/opus;'), /^no$/, '')) { Audio.opus = true ; } if (_AN_Call_replace('replace', audioElement.canPlayType('audio/mpeg;'), /^no$/, '')) { Audio.mp3 = true ; } if (_AN_Call_replace('replace', audioElement.canPlayType('audio/wav; codecs="1"'), /^no$/, '')) { Audio.wav = true ; } if (audioElement.canPlayType('audio/x-m4a;') || _AN_Call_replace('replace', audioElement.canPlayType('audio/aac;'), /^no$/, '')) { Audio.m4a = true ; } if (_AN_Call_replace('replace', audioElement.canPlayType('audio/webm; codecs="vorbis"'), /^no$/, '')) { Audio.webm = true ; } if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') { if (Browser.edge) { Audio.dolby = true ; } else if (Browser.safari && Browser.safariVersion >= 9) { if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) { var major = parseInt(RegExp.$1, 10); var minor = parseInt(RegExp.$2, 10); if ((major === 10 && minor >= 11) || major > 10) { Audio.dolby = true ; } } } } } } catch (e) { } return Audio; } module.exports = init();