玩特定的时间音频文件 [英] Playing audio file for specific time
本文介绍了玩特定的时间音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
家伙,我能够用媒体播放器播放音频文件。但我需要播放一段音频文件的具体时间。
Guys i able to play audio file using Mediaplayer. But i need to play a audio file for specific time.
例如:玩audio1.mp3至5分钟。
音频文件是10秒而已。不过它应该继续玩,直到5分钟。
Eg: play audio1.mp3 till 5 minutes. The audio file is of 10 seconds only.But it should keep playing till 5 minutes.
推荐答案
试试这个
mediaplayerplayer.setLooping(true);<--- this lets the audio to loop...
这就是倒数计时器
and this is the countdown timer
MyCount counter;
Long s1;
counter= new MyCount(300000,1000);
counter.start();
public void asdf(View v){ <---- method for onclick of buttons pause and resuming timer
switch(v.getId()){
case R.id.button1:<-- for pause
counter.cancel();
break;
case R.id.button2:<--- for resume
counter= new MyCount(s1,1000);
counter.start();
}
}
public class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
mediaplayer.stop();
mediaplayer.release();
}
@Override
public void onTick(long millisUntilFinished) {
s1=millisUntilFinished;
}
}
}
这可以帮助您暂停媒体播放器还与...一起定时器..和让你播放歌曲完整5分钟
this helps you to pause the mediaplayer also... along with timer.. and lets you play the song for complete 5 mins
这篇关于玩特定的时间音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文