onstop() for mp3 files

Posted by kostas_menu on Stack Overflow See other posts from Stack Overflow or by kostas_menu
Published on 2010-12-24T19:27:46Z Indexed on 2010/12/24 21:54 UTC
Read the original article Hit count: 252

Filed under:

i have this two button.as i press the first it plays an mp3 file.but if i press the second and the first mp3 hasnt finished yet,they play both together.how could i fix it??this is my btn code!!thanks

Button button = (Button) findViewById(R.id.btn);  
        button.setOnClickListener(new View.OnClickListener() {  
           public void onClick(View v){

            MediaPlayer mp = MediaPlayer.create(olympiakos.this, R.raw.myalo);  
            mp.start(); 
            Toast.makeText(olympiakos.this, "Eisai sto myalo", Toast.LENGTH_SHORT).show();

           }     

        });       

        Button button2 = (Button) findViewById(R.id.btn2);  
        button2.setOnClickListener(new View.OnClickListener() {  
           public void onClick(View v){

            MediaPlayer mp = MediaPlayer.create(olympiakos.this, R.raw.thryleole);  
            mp.start(); 
            Toast.makeText(olympiakos.this, "thryle ole trelenomai", Toast.LENGTH_SHORT).show();
           }

© Stack Overflow or respective owner

Related posts about android