Ejemplo n.º 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++;
   }
 }
Ejemplo n.º 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();
         }
       }
     }
   }
 }
Ejemplo n.º 3
0
 public synchronized void setSoundVolume(int vol) {
   if (asound != null) {
     asound.setVolume(vol);
   }
 }
Ejemplo n.º 4
0
 public synchronized void stopPlayer() {
   if (asound != null) {
     asound.stopPlayer();
     asound.release();
   }
 }
Ejemplo n.º 5
0
 public synchronized void resetSound() {
   if (asound != null) {
     asound.reset();
   }
 }