/**
 * 音频管理
 * author suo
 */ module FishingJoy { import Sound = egret . Sound ; export class SoundManager { private static _instance : SoundManager = null ; public curMusic : SOUND_BG = - 1 ; public constructor ( ) { } /**
         * 获得单例
         */ public static get instance ( ) : SoundManager { if ( this . _instance == null ) { this . _instance = new SoundManager ( ) ; } return this . _instance ; } /**
         * 获取音频方式一
         */ public getSoundMethodOne ( ) { var sound = new egret . Sound ( ) ; sound . addEventListener ( egret . Event . COMPLETE , function loadOver ( event ) { sound . play ( ) ; } , this ) ; sound . addEventListener ( egret . IOErrorEvent . IO_ERROR , function loadError ( event ) { console . log ( "loaded error!" ) ; } , this ) ; sound . load ( "resource/sound/sound.mp3" ) ; } /**
         * 获取音频方式二
         */ public getSoundMethodTwo ( ) { var loader = new egret . URLLoader ( ) ; loader . addEventListener ( egret . Event . COMPLETE , function loadOver ( event ) { var sound = loader . data ; sound . play ( ) ; } , this ) ; loader . dataFormat = egret . URLLoaderDataFormat . SOUND ; loader . load ( new egret . URLRequest ( "resource/sound/sound.mp3" ) ) ; } /**
         * 获取音频方式三
         */ public playSoundByName ( name , playTime = 1 ) { var sound = RES . getRes ( name ) ; if ( sound != null ) { uniLib . SoundMgr . instance . playSound ( name , playTime ) ; } else { console . assert ( false , "音源key为" + name + "不存在!" ) ; } } /**
         * 停止播放声音
         */ public stopSound ( name ) { if ( uniLib . SoundMgr . instance . isSoundPlaying ( name ) ) { uniLib . SoundMgr . instance . stopSound ( name ) ; } } /**
         * 获得声音
         */ public getSound ( name ) { return RES . getRes ( name ) ; } /**
         * 播放哪种背景音乐
         */ public playBG ( value ) { } /**
         * 释放
         */ public dispose ( ) { uniLib . SoundMgr . instance . stopSounds ( ) ; } } const enum SOUND_BG { NORMAL , RACE } }