public SoundHandle( SoundHandleID id ) {
				HandleID = id;
				Enabled = true;
				Path = "";
				IsLoop = true;
				LoopHeadPosition = 0.0;
				Volume = 100;
			}
 public SoundHandle(SoundHandleID id)
 {
     HandleID         = id;
     Enabled          = true;
     Path             = "";
     IsLoop           = true;
     LoopHeadPosition = 0.0;
     Volume           = 100;
 }
        public static string SoundHandleIDToString(SoundHandleID id)
        {
            switch (id)
            {
            case SoundHandleID.Port:
                return("母港");

            case SoundHandleID.Sortie:
                return("出撃中");

            case SoundHandleID.BattleDay:
                return("昼戦");

            case SoundHandleID.BattleNight:
                return("夜戦");

            case SoundHandleID.BattleAir:
                return("航空戦");

            case SoundHandleID.BattleBoss:
                return("ボス戦");

            case SoundHandleID.BattlePracticeDay:
                return("演習昼戦");

            case SoundHandleID.BattlePracticeNight:
                return("演習夜戦");

            case SoundHandleID.ResultWin:
                return("勝利");

            case SoundHandleID.ResultLose:
                return("敗北");

            case SoundHandleID.ResultBossWin:
                return("ボス勝利");

            case SoundHandleID.Record:
                return("戦績");

            case SoundHandleID.Item:
                return("アイテム");

            case SoundHandleID.Quest:
                return("任務");

            case SoundHandleID.Album:
                return("図鑑");

            case SoundHandleID.ImprovementArsenal:
                return("改修工廠");

            default:
                return("不明");
            }
        }
        public static string SoundHandleIDToString(SoundHandleID id)
        {
            switch (id)
            {
            case SoundHandleID.Port:
                return(ConstantsRes.Port);

            case SoundHandleID.Sortie:
                return(ConstantsRes.BGM_Sortie);

            case SoundHandleID.BattleDay:
                return(ConstantsRes.BGM_BattleDay);

            case SoundHandleID.BattleNight:
                return(ConstantsRes.BGM_BattleNight);

            case SoundHandleID.BattleAir:
                return(ConstantsRes.BGM_BattleAir);

            case SoundHandleID.BattleBoss:
                return(ConstantsRes.BGM_BattleBoss);

            case SoundHandleID.BattlePracticeDay:
                return("演習昼戦");

            case SoundHandleID.BattlePracticeNight:
                return("演習夜戦");

            case SoundHandleID.ResultWin:
                return("勝利");

            case SoundHandleID.ResultLose:
                return("敗北");

            case SoundHandleID.ResultBossWin:
                return("ボス勝利");

            case SoundHandleID.Record:
                return("戦績");

            case SoundHandleID.Item:
                return("アイテム");

            case SoundHandleID.Quest:
                return("任務");

            case SoundHandleID.Album:
                return("図鑑");

            case SoundHandleID.ImprovementArsenal:
                return("改修工廠");

            default:
                return(ConstantsRes.Unknown);
            }
        }
        public static string SoundHandleIDToString(SoundHandleID id)
        {
            switch (id)
            {
            case SoundHandleID.Port:
                return("母港");

            case SoundHandleID.Sortie:
                return("出击中");

            case SoundHandleID.BattleDay:
                return("昼战");

            case SoundHandleID.BattleNight:
                return("夜战");

            case SoundHandleID.BattleAir:
                return("航空战");

            case SoundHandleID.BattleBoss:
                return("BOSS 战");

            case SoundHandleID.BattlePracticeDay:
                return("演习昼战");

            case SoundHandleID.BattlePracticeNight:
                return("演习夜战");

            case SoundHandleID.ResultWin:
                return("胜利");

            case SoundHandleID.ResultLose:
                return("败北");

            case SoundHandleID.ResultBossWin:
                return("BOSS 胜利");

            case SoundHandleID.Record:
                return("战绩");

            case SoundHandleID.Item:
                return("物品");

            case SoundHandleID.Quest:
                return("任务");

            case SoundHandleID.Album:
                return("图鉴");

            case SoundHandleID.ImprovementArsenal:
                return("改修工厂");

            default:
                return("不明");
            }
        }
        public void ConfigurationChanged()
        {
            var c = Utility.Configuration.Config.BGMPlayer;

            Enabled = c.Enabled;

            if (c.Handles != null)
            {
                Handles = new IDDictionary <SoundHandle>(c.Handles);
            }

            if (!c.SyncBrowserMute)
            {
                IsMute = false;
            }

            // 設定変更を適用するためいったん閉じる
            _mp.Close();
            _currentSoundHandleID = (SoundHandleID)(-1);
        }
        private bool Play(SoundHandle sh)
        {
            if (Enabled &&
                sh != null &&
                sh.Enabled &&
                !string.IsNullOrWhiteSpace(sh.Path) &&
                sh.HandleID != _currentSoundHandleID)
            {
                if (File.Exists(sh.Path))
                {
                    _mp.Close();
                    _mp.SetPlaylist(null);
                    _mp.SourcePath = sh.Path;
                }
                else if (Directory.Exists(sh.Path))
                {
                    _mp.Close();
                    _mp.SetPlaylistFromDirectory(sh.Path);
                }
                else
                {
                    return(false);
                }

                _currentSoundHandleID = sh.HandleID;

                _mp.IsLoop           = sh.IsLoop;
                _mp.LoopHeadPosition = sh.LoopHeadPosition;
                if (!Utility.Configuration.Config.Control.UseSystemVolume)
                {
                    _mp.Volume = sh.Volume;
                }
                _mp.Play();

                return(true);
            }

            return(false);
        }
        public SyncBGMPlayer()
        {
            _mp = new MediaPlayer();

            if (!_mp.IsAvailable)
            {
                Utility.Logger.Add(3, "Windows Media Player のロードに失敗しました。音声の再生はできません。");
            }

            _mp.AutoPlay  = false;
            _mp.IsShuffle = true;

            _currentSoundHandleID = (SoundHandleID)(-1);
            _isBoss = false;


            Enabled = false;
            Handles = new IDDictionary <SoundHandle>();

            foreach (SoundHandleID id in Enum.GetValues(typeof(SoundHandleID)))
            {
                Handles.Add(new SoundHandle(id));
            }



            #region API register
            APIObserver o = APIObserver.Instance;

            o["api_port/port"].ResponseReceived += PlayPort;

            o["api_req_map/start"].ResponseReceived += PlaySortie;
            o["api_req_map/next"].ResponseReceived  += PlaySortie;

            o["api_req_sortie/battle"].ResponseReceived                     += PlayBattleDay;
            o["api_req_combined_battle/battle"].ResponseReceived            += PlayBattleDay;
            o["api_req_combined_battle/battle_water"].ResponseReceived      += PlayBattleDay;
            o["api_req_combined_battle/ec_battle"].ResponseReceived         += PlayBattleDay;
            o["api_req_combined_battle/each_battle"].ResponseReceived       += PlayBattleDay;
            o["api_req_combined_battle/each_battle_water"].ResponseReceived += PlayBattleDay;

            o["api_req_battle_midnight/battle"].ResponseReceived             += PlayBattleNight;
            o["api_req_battle_midnight/sp_midnight"].ResponseReceived        += PlayBattleNight;
            o["api_req_combined_battle/midnight_battle"].ResponseReceived    += PlayBattleNight;
            o["api_req_combined_battle/sp_midnight"].ResponseReceived        += PlayBattleNight;
            o["api_req_combined_battle/ec_midnight_battle"].ResponseReceived += PlayBattleNight;

            o["api_req_sortie/airbattle"].ResponseReceived             += PlayBattleAir;
            o["api_req_combined_battle/airbattle"].ResponseReceived    += PlayBattleAir;
            o["api_req_sortie/ld_airbattle"].ResponseReceived          += PlayBattleAir;
            o["api_req_combined_battle/ld_airbattle"].ResponseReceived += PlayBattleAir;

            o["api_req_practice/battle"].ResponseReceived += PlayPracticeDay;

            o["api_req_practice/midnight_battle"].ResponseReceived += PlayPracticeNight;

            o["api_req_sortie/battleresult"].ResponseReceived          += PlayBattleResult;
            o["api_req_combined_battle/battleresult"].ResponseReceived += PlayBattleResult;
            o["api_req_practice/battle_result"].ResponseReceived       += PlayBattleResult;

            o["api_get_member/record"].ResponseReceived += PlayRecord;

            o["api_get_member/payitem"].ResponseReceived += PlayItem;

            o["api_get_member/questlist"].ResponseReceived += PlayQuest;

            o["api_get_member/picture_book"].ResponseReceived += PlayAlbum;

            o["api_req_kousyou/remodel_slotlist"].ResponseReceived += PlayImprovementArsenal;

            #endregion

            Configuration.Instance.ConfigurationChanged += ConfigurationChanged;
            SystemEvents.SystemShuttingDown             += SystemEvents_SystemShuttingDown;
        }
 public static string SoundHandleIDToString( SoundHandleID id )
 {
     switch ( id ) {
         case SoundHandleID.Port:
             return "母港";
         case SoundHandleID.Sortie:
             return "出撃中";
         case SoundHandleID.BattleDay:
             return "昼戦";
         case SoundHandleID.BattleNight:
             return "夜戦";
         case SoundHandleID.BattleAir:
             return "航空戦";
         case SoundHandleID.BattleBoss:
             return "ボス戦";
         case SoundHandleID.BattlePracticeDay:
             return "演習昼戦";
         case SoundHandleID.BattlePracticeNight:
             return "演習夜戦";
         case SoundHandleID.ResultWin:
             return "勝利";
         case SoundHandleID.ResultLose:
             return "敗北";
         case SoundHandleID.ResultBossWin:
             return "ボス勝利";
         case SoundHandleID.Record:
             return "戦績";
         case SoundHandleID.Item:
             return "アイテム";
         case SoundHandleID.Quest:
             return "任務";
         case SoundHandleID.Album:
             return "図鑑";
         case SoundHandleID.ImprovementArsenal:
             return "改修工廠";
         default:
             return "不明";
     }
 }