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 8542611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:06:37+00:00 2026-06-11T12:06:37+00:00

I have two problem while running below code Mediaplayer is not stopping because it’s

  • 0

I have two problem while running below code

  1. Mediaplayer is not stopping because it’s one method mp.isPlaying() always returns false.
  2. Sometime i am getting invalid state exception.
try {
    String[] alerts = getResources().getStringArray(R.array.mp3files);
    int ch;
    StringBuffer fileContent = new StringBuffer("");
    FileInputStream fis = openFileInput("alertNo");
    byte[] buffer = new byte[1];
    int length;
    while ((length = fis.read(buffer)) != -1) {
        fileContent.append(new String(buffer));
    }
    String data = new String(fileContent);
    int position = Integer.parseInt(data);
    //m.setVolume(100, 100);
    if (m.isPlaying()) {
    m.stop();
    m.release();
    }
    AssetFileDescriptor descriptor = 
        MySettings.this.getAssets().openFd(alerts[position] + ".mp3");
    m.setDataSource(descriptor.getFileDescriptor(), 
        descriptor.getStartOffset(), descriptor.getLength());
    descriptor.close();
    m.prepare();
    m.start();
} catch (Exception e) {
    e.printStackTrace();
}
  • 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-06-11T12:06:38+00:00Added an answer on June 11, 2026 at 12:06 pm

    Check the documentation , once release is called there is no way to reuse the object. You will have to create another Mediaplayer.

    Quoted.

     after release() is called, it is in the End state
    

    and

    Once the MediaPlayer object is in the End state, it can no longer be used and there is no way to bring it back to any other state.

    So reinitialize the m object with a new Mediaplayer or reset it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two while loops running one after the other (not inside of each
Problem: I have two array where one produce a category and the second produce
I have two bits of code: a form and a jQuery function. My problem
I have just started studying JOGL and there is one problem. Below is simple
I have a question with my code. I have two threads running from the
I have two very similar programs, as follows. Program A: no problem when running,
We have the following problem while running the git fsck --full --strict command: error:
I Have two problem in this Case : I want to pass a JSON
I have a design problem: I have two threads, a heartbeat/control thread and a
i have a problem concerning a select query in MYSQL i have two different

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.