Disable audio player for safari

This commit is contained in:
RainLoop Team 2015-04-11 02:45:30 +04:00
parent af2815cd61
commit 39566292af
2 changed files with 33 additions and 14 deletions

View file

@ -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;

View file

@ -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}
*/