Reputation: 1866
In my app, i have a image gallery and while showing each image,an audio should play.This gallery contains more than 100 images.And i placed all my audio files in "raw" folder and the audio filename starts with the position of image.like 1.mp3,2.mp3 etc.
How can i play this audio dynamically .ie if the gallery is showing 10 th image,then 10.mp3 should play.
Thanks in advance.
Upvotes: 0
Views: 302
Reputation: 777
You should define two Integer Arrays , one for your Gallery Images and the Second for your SoundBoard
Integer[] gallery={R.drawable.first,R.drawable.second,.........etc.};
Integer[] soundBoard={R.raw.first,R.raw.second,.....etc};
The Index you use to show the Gallery Image should be used in the SoundBoard to play the sound using the MediaPlayer class and its Static method create() and play() for ever looping set the looping(true);
You can always stop when a new image is displayed and play another sound.
Upvotes: 1