Play a Sound - Help Me

All your problems with Audio, Video and Images.

Play a Sound - Help Me

Postby drag0zzo » Sun Feb 21, 2010 7:35 pm

Hello guys,
i would play e beep.mp3 in my android application when i show my AlertDialog.

How can i do it?

tnx
drag0zzo
Freshman
Freshman
 
Posts: 4
Joined: Sun Feb 07, 2010 10:17 pm

Top

Postby mrco » Tue Feb 23, 2010 2:03 pm

Try to use MediaPlayer
mrco
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Jan 15, 2010 11:31 am
Location: 2V Software

Postby Damonh » Fri Feb 26, 2010 12:58 pm

- Put your sound file in res/raw directory (and make sure R.java updates)

- To create the mediaplayer use
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. MediaPlayer myplayer;
  2.  
  3. myplayer = MediaPlayer.create(getBaseContext(), R.raw.yoursoundfile);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


- To play the sound once use
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myplayer.start();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Damonh
Junior Developer
Junior Developer
 
Posts: 18
Joined: Thu Jan 21, 2010 3:56 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 17 guests