Note that there are some explanatory texts on larger screens.

plurals
  1. POMedia Player Error (-19,0) on CountdownTimer
    primarykey
    data
    text
    <p>I've created a program which is repeatedly call the media player every onTick method on CountdownTimer</p> <p>Media Player Class</p> <pre><code>public class Buzzer extends Activity{ private MediaPlayer mp; private AssetFileDescriptor descriptor; private Context context; public Buzzer(Context context){ super(); this.context=context; } public void playBeep(){ play("beep.mp3"); } public void stop(){ if (mp.isPlaying()) { mp.stop(); mp.release(); } } private void play(String file){ try { mp = new MediaPlayer(); if (mp.isPlaying()) { mp.stop(); mp.release(); mp.reset(); mp = new MediaPlayer(); } descriptor= context.getAssets().openFd("audios/"+file); mp.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength()); descriptor.close(); mp.prepare(); mp.start(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void onResume(){ super.onResume(); } public void onDestroy(){ mp.stop(); mp.release(); super.onDestroy(); } } </code></pre> <p>//Main Activity</p> <pre><code> public class Main extends Activity { Timer timer; Buzzer buzzer; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); buzzer=new Buzzer(Main.this); timer=new Timer(24000,1000); timer.start(); } public class Timer extends CountDownTimer{ public ShotClock_CountdownTimer(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } public void onTick (long millisUntilFinished) { buzzer.playBeep(); } public void onFinish() { } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload