현재 원하는 기능 때문에 간단한 샘플을 만들었습니다.

하지만 생각대로 pause 가 이루어 지지 않습니다.

터치 이벤트( 다운 ) 의 경우 루프되는 사운드를 출력하고

터치 이벤트 ( 업 ) 의 경우 사운드를 멈추게 하려는 간단한것인데 생각되로 되지 않고

다시 다운 이벤트가 이루어 지면 그때 pause 가 이루어 집니다.

어느 부분이 잘 못 된 것일까요??;;;

import android.app.Activity;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
public class SoundPoolTest extends Activity {
 
 public ImageView img1;
 public ImageView img2;
 public ImageView img3;
 
 public SoundPool sound;
 
 public int sound1;
 public int sound2;
 public int sound3;
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main);
        
        init();
    }
    
    public void init() {
     
     sound = new SoundPool(1, AudioManager.STREAM_MUSIC, 0 );
     sound1 = sound.load( getApplicationContext(), R.raw.sound1, 0);
     sound2 = sound.load( getApplicationContext(), R.raw.sound2, 0);
     sound3 = sound.load( getApplicationContext(), R.raw.sound3, 0);
     
     img1 = (ImageView) findViewById( R.id.image1 );
     img1.setOnTouchListener( new OnTouchListener() {
   
   @Override
   public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
    
    switch ( event.getAction() ) {
    
    case MotionEvent.ACTION_DOWN:
     sound.play( sound1, 1, 1, 0, -1, 1);
     break;
     
    case MotionEvent.ACTION_UP:
     sound.pause( sound1 );     
     break;
    }
    
    return true;
   }
  });
     img2 = (ImageView) findViewById( R.id.image2 );
     img2.setOnTouchListener( new OnTouchListener() {
   
   @Override
   public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
    
    switch ( event.getAction() ) {
    
    case MotionEvent.ACTION_DOWN:
     
     sound.play( sound2, 1, 1, 0, -1, 1);
     break;
     
    case MotionEvent.ACTION_UP:
     sound.pause( sound2 );     
     break;
    }
    
    return true;
   }
  });
     img3 = (ImageView) findViewById( R.id.image3 );
     img3.setOnTouchListener( new OnTouchListener() {
   
   @Override
   public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
    
    switch ( event.getAction() ) {
    
    case MotionEvent.ACTION_DOWN:
     
     sound.play( sound3, 1, 1, 0, -1, 1);
     break;
     
    case MotionEvent.ACTION_UP:
     sound.pause( sound3 );     
     break;
    }
    
    return true;
   }
  });
    }
    
    
}