mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03: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;
|
var self = this;
|
||||||
|
|
||||||
this.obj = window.Audio ? new window.Audio() : null;
|
this.obj = this.createNewObject();
|
||||||
this.objForNotification = window.Audio ? new window.Audio() : null;
|
this.objForNotification = this.createNewObject();
|
||||||
|
|
||||||
this.supported = !Globals.bMobileDevice &&
|
this.supported = !Globals.bMobileDevice && !Globals.bSafari &&
|
||||||
this.obj && this.obj.canPlayType && this.obj.play &&
|
this.obj && '' !== this.obj.canPlayType('audio/mpeg');
|
||||||
'' !== this.obj.canPlayType('audio/mpeg;');
|
|
||||||
|
|
||||||
if (this.obj && this.supported)
|
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.objForNotification.src = Links.sound('new-mail.mp3');
|
||||||
|
|
||||||
$(this.obj).on('ended error', function () {
|
$(this.obj).on('ended error', function () {
|
||||||
|
|
@ -58,6 +48,20 @@
|
||||||
Audio.prototype.objForNotification = null;
|
Audio.prototype.objForNotification = null;
|
||||||
Audio.prototype.supported = false;
|
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 ()
|
Audio.prototype.paused = function ()
|
||||||
{
|
{
|
||||||
return this.supported ? !!this.obj.paused : true;
|
return this.supported ? !!this.obj.paused : true;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,21 @@
|
||||||
Globals.sUserAgent = 'navigator' in window && 'userAgent' in window.navigator &&
|
Globals.sUserAgent = 'navigator' in window && 'userAgent' in window.navigator &&
|
||||||
window.navigator.userAgent.toLowerCase() || '';
|
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}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue