public void playBGM(string fileName, int volume)
        {
            if (bgmTask != null)
            {
                if (Path.GetFileName(bgmTask.filePath) == fileName)
                {
                    // case when only volume was changed
                    if (bgmTask.volume != volume)
                    {
                        bgmVolume = volume;
                        bgmTask.changeVolume(volume);
                    }

                    return;
                }

                bgmTask.stop();
                bgmTask = null;
            }

            bgmFilePath = libraryManager.soundFilePath(libraryManager.soundIndex(fileName));
            bgmVolume   = volume;
            if (bgmFilePath != "")
            {
                try {
                    bgmTask = new TSoundTask(bgmFilePath, volume, true, onBGMStopped);
                    bgmTask.play();
                } catch (Exception ex) {
                    Console.WriteLine(ex.Message);
                    bgmTask = null;
                }
            }
        }
 public void playVoice(string fileName, int volume, bool loop)
 {
     lock (voiceTasks) {
         string filePath = libraryManager.soundFilePath(libraryManager.soundIndex(fileName));
         if (filePath != "")
         {
             try {
                 TSoundTask task = new TSoundTask(filePath, volume, loop, onVoiceStopped);
                 task.play();
                 voiceTasks.Add(task);
             } catch (Exception ex) {
                 Console.WriteLine(ex.Message);
             }
         }
     }
 }
        public void playBGM()
        {
            if (bgmTask != null)
            {
                return;
            }

            if (bgmFilePath != "")
            {
                try {
                    bgmTask = new TSoundTask(bgmFilePath, bgmVolume, true, onBGMStopped);
                    bgmTask.play();
                } catch (Exception ex) {
                    Console.WriteLine(ex.Message);
                    bgmTask = null;
                }
            }
        }