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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:14:32+00:00 2026-05-23T02:14:32+00:00

I am new to android and I’m trying to develop an app where I

  • 0

I am new to android and I’m trying to develop an app where I take two music file. When the app starts the first music plays nd when the user clicks a button the second music plays and the first music has to fade out slowly.

I have tried it but i ended up with playing two music files one after the other. I am not able to get how to bring the fade out effect.

Here is my sample code

package com.Audio;

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

public class DemoAudio extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MediaPlayer mp=MediaPlayer.create(getBaseContext(), R.raw.fruit_dance);
        mp.start();
        mp.setVolume(1.0f, 1.0f);

        Button btn=(Button) findViewById(R.id.xBtn);
        btn.setOnTouchListener(new OnTouchListener(){
            @Override
            public boolean onTouch(View v, MotionEvent event){
                if(event.getAction()==MotionEvent.ACTION_DOWN){
                    final MediaPlayer mp1=MediaPlayer.create(getBaseContext(), R.raw.futurebells_full);
                    mp1.start();
                    mp1.setVolume(5.0f, 5.0f);
                }
                return true;
            }
        });
     }

}

Any help will be appreciated. Thanks a lot.

  • 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-23T02:14:32+00:00Added an answer on May 23, 2026 at 2:14 am

    I got the answer for it. I have created two separate objects for MediaPlayer and by using some methods i have adjusted their volumes the first music to lower the pitch and the second one to higher the pitch and this is what i wanted.

    This can be achieved well by using threads, it seems to work more better than by setting volumes directly.

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

Sidebar

Related Questions

I'm trying to record audio this.recorder = new android.media.MediaRecorder(); this.recorder.setAudioSource(android.media.MediaRecorder.AudioSource.MIC); this.recorder.setOutputFormat(android.media.MediaRecorder.OutputFormat.DEFAULT); this.recorder.setAudioEncoder(android.media.MediaRecorder.AudioEncoder.DEFAULT); this.recorder.setOutputFile(pruebaAudioRecorder.mp4); **this.recorder.prepare();**
I'm new to Android and I think I'm trying to do something really basic:
New Android developer here. I'm following a tutorial at http://www.vogella.de/ . The first applications
When creating a new android project, the build target has two choices: Android 2.2,
I have a new android app I put on the marketplace a few days
I was reading the new Android Design Standards here: http://developer.android.com/design/patterns/selection.html and was wondering first
My new Android app is crashing when I run it on my phone, but
I am new android. How add the JAR file in the android sdk and
I am a new android developer trying to write a simple contact book. When
The new Android in-app billing (http://developer.android.com/guide/market/billing/billing_testing.html) page says: To test in-app billing in an

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.