1. Are you ready for the Galaxy S20? Here is everything we know so far!

mediaplayer doesn't play in switch case my program is

Discussion in 'Android Help' started by Android Question, Feb 26, 2016.

  1. Android Question

    Thread Starter

    package in.research.hash_table;

    import android.media.AudioManager;
    import android.media.MediaPlayer;
    import android.media.SoundPool;
    import android.os.Bundle;

    import android.support.v7.app.AppCompatActivity;
    import android.widget.TextView;

    import java.util.HashMap;
    import java.util.Hashtable;
    import java.util.Scanner;


    public class MainActivity extends AppCompatActivity {

    public static Hashtable<String, Integer> LUT=new Hashtable<String, Integer>();;
    private MediaPlayer meadiaPlayer=new MediaPlayer();
    private static final String str="amio";
    Scanner s=new Scanner(str);
    TextView tv1,tv2;

    int count=0;
    SoundPool soundPool;
    int soundId;

    MediaPlayer mp;

    HashMap<String,Integer>ht=new HashMap<String,Integer>();

    @override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    soundPool=new SoundPool(1, AudioManager.STREAM_MUSIC,1);
    soundId=soundPool.load(this,R.raw.thu,1);
    soundPool.play(soundId, 1, 1, 1, 1, 1f);


    tv1=(TextView)findViewById(R.id.tv1);
    tv2=(TextView)findViewById(R.id.tv2);
    tv1.append(str);
    for(int i=0;i<str.length();i++){
    if(Character.toString(str.charAt(i)).matches("[ameiou]")){
    switch(Character.toString(str.charAt(i))){

    case "a":
    tv2.append("a");
    mp=MediaPlayer.create(this,R.raw.a);

    break;
    case "m":
    tv2.append("m");
    mp=MediaPlayer.create(this,R.raw.m);

    break;
    case "i":
    tv2.append("i");
    mp=MediaPlayer.create(this,R.raw.i);

    break;
    case "o":
    tv2.append("o");
    mp=MediaPlayer.create(this,R.raw.o);


    break;
    case "u":
    tv2.append("u");

    break;
    }





    }

    mp.start();
    count++;



    }













    }




    }
     


Loading...
Similar Threads - mediaplayer doesn't play
  1. julianr7
    Replies:
    1
    Views:
    143
  2. nPing
    Replies:
    3
    Views:
    288
  3. Dougie Nucleus
    Replies:
    3
    Views:
    338
  4. Joysocute1
    Replies:
    2
    Views:
    280
  5. AndroidGUIIsComplicated
    Replies:
    0
    Views:
    361
  6. muselladaniele1992
    Replies:
    4
    Views:
    858
  7. Rachaita
    Replies:
    0
    Views:
    157
  8. raccoon95
    Replies:
    0
    Views:
    532
  9. Arnold Balan
    Replies:
    1
    Views:
    400
  10. Teedeemiles
    Replies:
    0
    Views:
    1,228

Share This Page

Loading...