Esempio n. 1
0
 public void PlayAudioLoop(string filename, bool play, bool restart)
 {
     if (!enabled)
     {
         return;
     }
     if (context == null)
     {
         return;
     }
     //todo: resume playing.
     if (play)
     {
         if (!soundsplaying.ContainsKey(filename))
         {
             var x = new AudioTask(d_GameExit, filename, this);
             x.loop = true;
             soundsplaying[filename] = x;
         }
         if (restart)
         {
             soundsplaying[filename].Restart();
         }
         soundsplaying[filename].Play();
     }
     else
     {
         if (soundsplaying.ContainsKey(filename))
         {
             soundsplaying[filename].shouldplay = false;
             //soundsplaying.Remove(filename);
         }
     }
 }
Esempio n. 2
0
 public void PlayLoop(AudioSample sample, bool play, bool restart, float x, float y, float z)
 {
     if (sample == null)
     {
         return;
     }
     if (context == null)
     {
         return;
     }
     if (play)
     {
         if (!soundsplaying.ContainsKey(sample))
         {
             soundsplaying[sample]      = new AudioTask(sample, this, x, y, z);
             soundsplaying[sample].loop = true;
         }
         if (restart)
         {
             soundsplaying[sample].Restart();
         }
         soundsplaying[sample].shouldplay = true;
         soundsplaying[sample].Play();
     }
     else
     {
         if (soundsplaying.ContainsKey(sample))
         {
             soundsplaying[sample].shouldplay = false;
         }
     }
 }
Esempio n. 3
0
 public void removeTask(string path)
 {
     if (tasks.ContainsKey(path))
     {
         AudioTask task = tasks[path];
         tasks.Remove(path);
         task.onDispose();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 加载clip
 /// </summary>
 /// <param name="path"></param>
 /// <param name="callBack"></param>
 private void loadClip(string path, Action <AudioClip> callBack)
 {
     if (AssetMgr.isHave(path))
     {
         TBundle tb = AssetMgr.getBundle(path);
         if (callBack != null)
         {
             callBack(tb.Ab.LoadAsset <AudioClip>(getAudioName(path)));
         }
     }
     else
     {
         //需要加载ab
         if (tasks.ContainsKey(path))
         {
             tasks[path].addHandler(callBack);
         }
         else
         {
             AudioTask task = new AudioTask(path, callBack);
             tasks.Add(path, task);
         }
     }
 }
Esempio n. 5
0
 public void PlayAudioLoop(string filename, bool play, bool restart)
 {
     if (!enabled)
     {
         return;
     }
     if (context == null)
     {
         return;
     }
     //todo: resume playing.
     if (play)
     {
         if (!soundsplaying.ContainsKey(filename))
         {
             var x = new AudioTask(d_GameExit, filename, this);
             x.loop = true;
             soundsplaying[filename] = x;
         }
         if (restart)
         {
             soundsplaying[filename].Restart();
         }
         soundsplaying[filename].Play();
     }
     else
     {
         if (soundsplaying.ContainsKey(filename))
         {
             soundsplaying[filename].shouldplay = false;
             //soundsplaying.Remove(filename);
         }
     }
 }
Esempio n. 6
0
 static void PutAudioTask(AudioTask task)
 {
     audioTaskPool.Enqueue(task);
 }
Esempio n. 7
0
 public void PlayLoop(AudioSample sample, bool play, bool restart, float x, float y, float z)
 {
     if (sample == null)
     {
         return;
     }
     if (context == null)
     {
         return;
     }
     if (play)
     {
         if (!soundsplaying.ContainsKey(sample))
         {
             soundsplaying[sample] = new AudioTask(sample, this, x, y, z);
             soundsplaying[sample].loop = true;
         }
         if (restart)
         {
             soundsplaying[sample].Restart();
         }
         soundsplaying[sample].shouldplay = true;
         soundsplaying[sample].Play();
     }
     else
     {
         if (soundsplaying.ContainsKey(sample))
         {
             soundsplaying[sample].shouldplay = false;
         }
     }
 }