Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.06 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.         }