Playing an mp3 when someone clicks a button

All your problems with Audio, Video and Images.

Playing an mp3 when someone clicks a button

Postby arberb » Mon Apr 26, 2010 11:38 pm

I am creating a soundboard and I want my app to play an Mp3 when someone clicks a button. How would I do this ?
This is my main
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package org.me.test;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.os.Bundle;
  8.  
  9. import android.widget.Button;
  10.  
  11.  
  12.  
  13. public class MainActivity extends Activity {
  14.  
  15.  
  16.  
  17.     @Override
  18.  
  19.     public void onCreate(Bundle savedInstanceState) {
  20.  
  21.         super.onCreate(savedInstanceState);
  22.  
  23.         this.setContentView(R.layout.main);
  24.  
  25.         Button myButton = (Button) findViewById(R.id.my_button);
  26.  
  27.  
  28.  
  29.     }
  30.  
  31. }
  32.  
  33.  
Parsed in 0.061 seconds, using GeSHi 1.0.8.4
arberb
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Apr 19, 2010 12:08 pm

Top

Postby Graham » Sun May 02, 2010 11:52 am

http://www.anddev.org/video-tut_-_playi ... -t156.html

So on your button click event you want something like
import android.media.MediaPlayer;
and use the MediaPlayer class to play sounds.
-- Graham
Graham
Freshman
Freshman
 
Posts: 7
Joined: Sun Mar 22, 2009 10:18 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 13 guests