Hi I am making a slide show.images slide automatically in slide show these images are user selected images stored in array.now i want to plat user selected audio along with animation.but i don't know how to do this.the images animation is working fine but canot play sound at background.here is my code
final Handler mHandler = new Handler();
// Create runnable for posting
final Runnable mUpdateResults = new Runnable() {
public void run() {
AnimateandSlideShow();
}
};
// mHandler.postDelayed(mUpdateResults, 300);
int delay =300; // delay for 1 sec.
int period = 9000; // repeat every 4 sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
mHandler.post(mUpdateResults);
}
}, delay, period);
////////end animation//////////////////
here is the animatedslideshow function:
private void AnimateandSlideShow() {
// playsound();
// sound =new AnimationSound(SlideShow.this,uriaudio);
// sound.startsound();
iv=(ImageView)findViewById(R.id.anim_view);
iv.setImageURI(Uri.parse(allimgs.get(count%allimgs.size()).toString()));
count++;
anim = AnimationUtils.loadAnimation(SlideShow.this, R.anim.fade_in);
// load your desire animation.
iv.startAnimation(anim);
}
and playsound:
private void playsound()
{
MediaPlayer player = MediaPlayer.create(SlideShow.this, uriaudio);
player.setLooping(false); // Set looping
player.setVolume(100,100);
player.start();
}
i don't know where to put the playsound function in handler so that audio starts with animation.