Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6146687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:59:15+00:00 2026-05-23T18:59:15+00:00

private void playSound(){ Log.d(TAG,Play SOund); new Thread(new Runnable() { public void run() { MediaPlayer

  • 0
private void playSound(){
        Log.d(TAG,"Play SOund");
        new Thread(new Runnable() {
            public void run() {
                MediaPlayer mPlayer = MediaPlayer.create(mainActivity, R.raw.button_6);
                Log.d(TAG,"DURATION ::-->>"+ mPlayer.getDuration());
                mPlayer.start();
            }
        }).start();
        Log.d(TAG,"END OF Play SOund");
    }

When I use a small mp3 file inside raw folder my applications gives me a small sound. Some ting like a noise of 0.3 seconds. But if i use a large mp3 then i get the following exception

02-01 10:06:53.298: ERROR/AndroidRuntime(10754): FATAL EXCEPTION: Thread-11
02-01 10:06:53.298: ERROR/AndroidRuntime(10754): android.content.res.Resources$NotFoundException: Resource ID #0x7f040001

Can any one suggest what am i doing wrong here ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:59:15+00:00Added an answer on May 23, 2026 at 6:59 pm

    It seems the system needs to wait until the player finishers playing. Else the next line starts to execute and once the code is finished mp3 or the audios stops. So what i did was shown below. And it works 🙂

    new Thread(new Runnable() {
                public void run() {
                    try{
                        mPlayer = MediaPlayer.create(MarketHome.this, R.raw.music);
                        mPlayer.setLooping(true);
                        mPlayer.start();
                        while(mPlayer.isPlaying()){
                            android.os.SystemClock.sleep(100);
                        }
                    }catch(Exception e){
                        Log.d(TAG,"ERROR PLAYING");
                        e.printStackTrace();
                    }
                }}).start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private function playSound():void { _soundChannel = _soundObj.play(); _soundChannel.addEventListener(Event.SOUND_COMPLETE, nextTrack); } <s:Button width=35 label=>> click=nextTrack();/>
private void setActionViewListener(final String uri) { mediaButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v)
public class PlayAudio extends BroadcastReceiver{ private Context mContext; MediaPlayer mp; @Override public void onReceive(Context
private void validateXML(DOMSource source) throws Exception { URL schemaFile = new URL(http://www.csc.liv.ac.uk/~valli/modules.xsd); SchemaFactory schemaFactory
private void BindCountry() { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath(countries.xml)); foreach (XmlNode node in
private void refineWords() { for(String word : words){ Log.i(word, word); if (word == s
private void btnSend_Click(object sender, RoutedEventArgs e) { Button obj=(Button)sender; obj.Content=Cancel; SendImage send = new
I defined the following Sound Class to play Sound in my Pacman Game: public
private void mnuCustomerAdd_Click(object sender, EventArgs e) { CustomerForm frmCust = new CustomerForm(Add A New
private void PreventPageFromBeingCached(AuthorizationContext filterContext) { var cachePolicy = filterContext.HttpContext.Response.Cache; cachePolicy.SetProxyMaxAge(new TimeSpan(0)); } The reason

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.