예제 #1
0
 public synchronized void playSound(String name, boolean loop) {
   if (paused) {
     return;
   }
   if (sounds.containsKey(name)) {
     ((AssetsSound) sounds.get(name)).play();
   } else {
     if (clipCount > MAX_CLIPS) {
       int idx = sounds.size() - 1;
       String k = (String) sounds.keySet().toArray()[idx];
       AssetsSound clip = (AssetsSound) sounds.remove(k);
       clip.release();
       clip = null;
       clipCount--;
     }
     asound = new AssetsSound(context);
     asound.setDataSource(name);
     if (loop) {
       asound.loop();
     } else {
       asound.play();
     }
     sounds.put(name, asound);
     clipCount++;
   }
 }
예제 #2
0
 public synchronized void stopSoundAll() {
   if (sounds != null) {
     for (Iterator<?> it = sounds.iterator(); it.hasNext(); ) {
       Entry<?, ?> sound = (Entry<?, ?>) it.next();
       if (sound != null) {
         AssetsSound as = (AssetsSound) sound.getValue();
         if (as != null) {
           as.stop();
         }
       }
     }
   }
 }
예제 #3
0
 public synchronized void setSoundVolume(int vol) {
   if (asound != null) {
     asound.setVolume(vol);
   }
 }
예제 #4
0
 public synchronized void stopPlayer() {
   if (asound != null) {
     asound.stopPlayer();
     asound.release();
   }
 }
예제 #5
0
 public synchronized void resetSound() {
   if (asound != null) {
     asound.reset();
   }
 }