java - Android Media Player Stuttering with CountDownTimer -
i'm trying make app teach how count music. media player initialize 30 second sound clip of persistent note. using countdown timer tell media player when pause , play. code below causes first , last second of audio stutter.
mediaplayer mymediaplayer = mediaplayer.create(musiccounting.this, r.raw.a_note); countdowntimer time = new countdowntimer(4000,500) { @override public void ontick(long millisuntilfinished) { if(mymediaplayer.isplaying()) { mymediaplayer.pause(); } else { mymediaplayer.start(); } } @override public void onfinish() { mymediaplayer.pause(); mymediaplayer.seekto(0); } }; time.start();
this code quarter notes , eighth notes code looks identical except second parameter countdown timer 250. suggestions appreciated. :)
there lots of reports of android mediaplayer stutter various ways try fix it. seems best related question:
however, audiotrack might better particular situation want play specific notes. see:
Comments
Post a Comment