Sound Doesnt Play When Someone Clicks The BUtton

All your problems with Audio, Video and Images.

Sound Doesnt Play When Someone Clicks The BUtton

Postby arberb » Tue Apr 27, 2010 1:16 am

CLOSE THREAD
Last edited by arberb on Tue Apr 27, 2010 12:11 pm, edited 1 time in total.
arberb
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Apr 19, 2010 12:08 pm

Top

Postby hkswaroop » Tue Apr 27, 2010 7:17 am

Hope this helps

public class test extends Activity {
Button b;
MediaPlayer MPX ;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b=(Button) findViewById(R.id.Button01);

MPX = MediaPlayer.create(test.this, R.raw.a);

b.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

try {
MPX.start();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
hkswaroop
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed May 20, 2009 8:15 am
Location: Bangalore

Postby arberb » Tue Apr 27, 2010 11:43 am

hkswaroop wrote:Hope this helps

public class test extends Activity {
Button b;
MediaPlayer MPX ;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b=(Button) findViewById(R.id.Button01);

MPX = MediaPlayer.create(test.this, R.raw.a);

b.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

try {
MPX.start();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}

This makes my app crashes when you open it :S
arberb
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Apr 19, 2010 12:08 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 7 guests