Guest User

Untitled

a guest
May 5th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public void playRecording(View view) {
  2.  
  3. mp = new MediaPlayer();
  4. try {
  5. if(new File(audiofile.getAbsolutePath())!=null)
  6. {
  7. mp.setDataSource(audiofile.getAbsolutePath());
  8. mp.setOnCompletionListener(new OnCompletionListener() {
  9.  
  10. public void onCompletion(MediaPlayer mp) {
  11. // TODO Auto-generated method stub
  12. Toast.makeText(MainActivity.this, "complete", Toast.LENGTH_SHORT).show();
  13.  
  14.  
  15.  
  16. if(counter >= limit)
  17. {
  18. mp.stop();
  19. }
  20. else
  21. {
  22. mp.start();
  23. }
  24. counter++;
  25.  
  26. }
  27. });
  28.  
  29. mp.setVolume(100, 100);
  30.  
  31. mp.prepare();
  32. mp.start();
  33. }
  34. else
  35. {
  36. Toast.makeText(MainActivity.this, "Pleast Record A File", Toast.LENGTH_LONG).show();
  37. }
  38. } catch (IllegalArgumentException e) {
  39. // TODO Auto-generated catch block
  40. e.printStackTrace();
  41. } catch (IllegalStateException e) {
  42. // TODO Auto-generated catch block
  43. e.printStackTrace();
  44. } catch (IOException e) {
  45. // TODO Auto-generated catch block
  46. e.printStackTrace();
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment