Code refactoring

Flow first look
This commit is contained in:
RainLoop Team 2016-09-10 01:38:16 +03:00
parent 2f841524cb
commit e6e0b02849
71 changed files with 2092 additions and 1836 deletions

View file

@ -7,18 +7,20 @@ import {trim} from 'Common/Utils';
class Audio
{
notificator = null;
player = null;
supported = false;
supportedMp3 = false;
supportedOgg = false;
supportedWav = false;
supportedNotification = false;
constructor() {
this.notificator = null;
this.supportedMp3 = false;
this.supportedOgg = false;
this.supportedWav = false;
this.supportedNotification = false;
this.player = this.createNewObject();
this.supported = !bMobileDevice && !bSafari && !!this.player && !!this.player.play;
if (this.supported && this.player.canPlayType)
if (this.supported && this.player && this.player.canPlayType)
{
this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, '');
this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, '');
@ -35,7 +37,7 @@ class Audio
this.supportedNotification = false;
}
if (this.supported)
if (this.supported && this.player)
{
const stopFn = () => this.stop();
@ -137,4 +139,4 @@ class Audio
}
}
module.exports = new Audio();
export default new Audio();