diff --git a/dev/Common/Audio.js b/dev/Common/Audio.js index fd3b324a1..d4e3046d0 100644 --- a/dev/Common/Audio.js +++ b/dev/Common/Audio.js @@ -20,24 +20,14 @@ { var self = this; - this.obj = window.Audio ? new window.Audio() : null; - this.objForNotification = window.Audio ? new window.Audio() : null; + this.obj = this.createNewObject(); + this.objForNotification = this.createNewObject(); - this.supported = !Globals.bMobileDevice && - this.obj && this.obj.canPlayType && this.obj.play && - '' !== this.obj.canPlayType('audio/mpeg;'); + this.supported = !Globals.bMobileDevice && !Globals.bSafari && + this.obj && '' !== this.obj.canPlayType('audio/mpeg'); if (this.obj && this.supported) { - this.obj.preload = 'none'; - this.obj.loop = false; - this.obj.autoplay = false; - this.obj.muted = false; - - this.objForNotification.preload = 'none'; - this.objForNotification.loop = false; - this.objForNotification.autoplay = false; - this.objForNotification.muted = false; this.objForNotification.src = Links.sound('new-mail.mp3'); $(this.obj).on('ended error', function () { @@ -58,6 +48,20 @@ Audio.prototype.objForNotification = null; Audio.prototype.supported = false; + Audio.prototype.createNewObject = function () + { + var obj = window.Audio ? new window.Audio() : null; + if (obj && obj.canPlayType) + { + obj.preload = 'none'; + obj.loop = false; + obj.autoplay = false; + obj.muted = false; + } + + return obj; + }; + Audio.prototype.paused = function () { return this.supported ? !!this.obj.paused : true; diff --git a/dev/Common/Globals.js b/dev/Common/Globals.js index 1cad8c6c4..b408c073a 100644 --- a/dev/Common/Globals.js +++ b/dev/Common/Globals.js @@ -63,6 +63,21 @@ Globals.sUserAgent = 'navigator' in window && 'userAgent' in window.navigator && window.navigator.userAgent.toLowerCase() || ''; + /** + * @type {boolean} + */ + Globals.bIE = Globals.sUserAgent.indexOf('msie') > -1; + + /** + * @type {boolean} + */ + Globals.bChrome = Globals.sUserAgent.indexOf('chrome') > -1; + + /** + * @type {boolean} + */ + Globals.bSafari = !Globals.bChrome && Globals.sUserAgent.indexOf('safari') > -1; + /** * @type {boolean} */