Ejemplo n.º 1
0
 public void RefreshSoundsList()
 {
     SoundsInfoList.Clear();
     LoadSoundsByPath(GameConfig.RadioSoundsPath);
     LoadSoundsByPath(GameConfig.OSTSoundsPath);
     if (!string.IsNullOrEmpty(CurSoundInfo.FilePath))
     {
         //如果当前播放的音乐还存在,就刷新当前音乐的下标
         if (File.Exists(CurSoundInfo.FilePath))
         {
             CurSoundsIndex = SoundsInfoList.FindIndex(a => a.FilePath == CurSoundInfo.FilePath);
         }
         else
         {
             StopCurSound();
             CurSoundsIndex = -1;
         }
     }
 }
Ejemplo n.º 2
0
 void LoadSoundsByPath(string path)
 {
     if (Directory.Exists(path))
     {
         string[] filePaths = Directory.GetFiles(path);
         if (null != filePaths && filePaths.Length > 0)
         {
             string tempStr;
             for (int i = 0; i < filePaths.Length; i++)
             {
                 tempStr = filePaths[i];
                 if (m_NAudioSupportFormat.Any(a => tempStr.ToLower().EndsWith("." + a.ToLower())) ||
                     m_UnitySupportFormat.Any(b => tempStr.ToLower().EndsWith("." + b.ToLower())))
                 {
                     SoundsInfoList.Add(new RadioFileInfo(tempStr));
                 }
             }
         }
     }
 }