Playing 4 audio files one after another

All your problems with Audio, Video and Images.

Playing 4 audio files one after another

Postby wh33t » Tue Nov 17, 2009 7:32 pm

Hi,

I need help on being able to play 4 raw resource audio files 1 after another. Ideally i need to be able to load 4 sounds into a type of playlist and then play the playlist once. Has anyone tried to do this and succeeded?

All help is greatly appreciated
wh33t
Freshman
Freshman
 
Posts: 3
Joined: Sat Jul 11, 2009 2:21 pm

Top

Postby purvi » Wed Dec 09, 2009 5:19 pm

Hi,

You can use the SoundPool Media API for this, where you load the 4 raw files to the soundpool object using a hashmap and a key is provided to each file to play.

and then play the file fromthe soundpool using soundpool.play()

Thanks.
Regards,
Purvi
purvi
Junior Developer
Junior Developer
 
Posts: 10
Joined: Mon Oct 19, 2009 2:52 pm

Postby saamyandroid » Tue Dec 15, 2009 7:06 pm

Hi Purvi ,

can u give some sample code to play more than one sound using soundPool.

i faced some problems while using Media Player Class .
saamyandroid
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA

Postby purvi » Tue Dec 15, 2009 7:27 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. SoundPool sp;
  3.  
  4. // hashmap to store the audio files
  5.  
  6. HashMap<Integer, Integer> hmap = new HashMap<Integer, Integer>();
  7.  
  8. // load the audio (sound Id, sound)
  9.  
  10. hmap.put(1,sp.load());
  11.  
  12. hmap.put(2, sp.load());...
  13.  
  14.  
  15.  
  16. // Depending upon the size of the audio give soundpool time to load it. if play called immediately and audio not
  17.  
  18. //loaded there is no play. use soundpool when the length of sound is known and is comparatively less.
  19.  
  20.  
  21.  
  22. // call the soundpool to play
  23.  
  24. sp.play(hmap.get(soundID));
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


What problem you are facing with mediaplayer?
purvi
Junior Developer
Junior Developer
 
Posts: 10
Joined: Mon Oct 19, 2009 2:52 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 10 guests