mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 12:32:40 +08:00
Disable audio player for safari
This commit is contained in:
parent
af2815cd61
commit
39566292af
2 changed files with 33 additions and 14 deletions
|
@ -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;
|
||||
|
|
|
@ -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}
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue