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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:55:40+00:00 2026-06-10T00:55:40+00:00

I am trying to run a mp3 file using media player.It compiles fine,but it

  • 0

I am trying to run a mp3 file using media player.It compiles fine,but it is not playing the mp3 file.Even when i checked the isPlaying(),it returns false. Please tell me what is the problem with it. This is the code:

package com.example.soundplayer;

import java.io.IOException;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

    /**
     * Variables
     */
    MediaPlayer mp = null;
    String hello = "Hello!";
    String goodbye = "GoodBye!";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /**
         * Talking with the buttonHello
         */
        final Button buttonHello = (Button) findViewById(R.id.idHello);
        buttonHello.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                managerOfSound(hello);
            } // END onClick()
        }); // END buttonHello
    }     
    /**
     * Manager of Sounds
     */
    protected void managerOfSound(String theText) {
        mp = MediaPlayer.create(MainActivity.this, R.raw.sound);
        mp = new MediaPlayer();
        if (theText.equals(hello))
        {
            MediaPlayer.create(this, R.raw.sound);
            mp.setVolume(1.0F, 1.0F);
            mp.reset();
            try {
                mp.prepare();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (mp != null) {
                mp.start();
            }
            if(mp.isPlaying()== true){
                Toast.makeText(this, "mp is playing ", Toast.LENGTH_LONG).show();}
        }
    }
}
  • 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-10T00:55:41+00:00Added an answer on June 10, 2026 at 12:55 am

    try below code

    protected void managerOfSound(String theText) {
        mp = MediaPlayer.create(MainActivity.this, R.raw.sound);
        mp.setVolume(1.0F, 1.0F);
        if (theText.equals(hello))
        {            
            if (mp != null) {
                mp.start();
            }
            if(mp.isPlaying()== true){
                Toast.makeText(this, "mp is playing ", Toast.LENGTH_LONG).show();}
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run a mp3 file using android media player. I'm using this
I am trying to play and audio file using DirectX dll. Audio.FromFile(Message 1.mp3).Play(); But
I'm trying to read the duration out of an mp3 file using ruby-mp3info and
I am trying to convert a flv file to mp3 using ffmpeg from java.
I am trying to create an MP3 Player where the music carries on playing
I am trying run a batch file from my java codes, but unfortunately I
I'm trying to build a streaming .mp3 player to run various sound files on
Im trying to implement fade in effect to my mp3 player. I´m using FloatControl
I am trying to run a sound file in Java using this code: public
I am trying to upload a mp3 file from my android device(2.3.3) but failing.

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.