Need help getting app to play sounds

All your problems with Audio, Video and Images.

Need help getting app to play sounds

Postby ericmahlon » Thu Aug 26, 2010 6:17 pm

In my class I have an OnTouchEvent and when a certain area is clicked, it will play a sound (Not sure if this is the best way to go about this?). However I have been running into bugs using the MediaPlayer. Sound will double play and then eventually sound will stop completely. I am wondering how to efficiently play 5 sounds. The user will be clicking the screen in different areas and different sounds will be playing. I have the attached code below but it only has the first area....say I add in another area how would I go about changing the media player to play a different sound.

Code: Select all
    public boolean onTouchEvent(MotionEvent e)
        x = e.getX();
        y = e.getY();
        if (x >= 232 && x<=287 && y>=117 && y<=157) {
             //PLAY SOUND
        return true;
Junior Developer
Junior Developer
Posts: 19
Joined: Mon Jul 05, 2010 9:00 pm


Re: Need help getting app to play sounds

Postby blundell » Fri Aug 27, 2010 12:23 pm

You need to extract your media player to a seperate class and ensure that you are keeping it in the correct state ... index.html is your best reference ... Audio.html is a code example of a media class
User avatar
Master Developer
Master Developer
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 14 guests