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

  • Home
  • SEARCH
  • 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 6220393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:56:57+00:00 2026-05-24T07:56:57+00:00

I am trying to create a music streaming app. So far it works just

  • 0

I am trying to create a music streaming app.
So far it works just fine.
I am using the

MediaPlayer.create(thisContext, Uri.parse(PATH_TO_STREAM));

convenience method to prepare the infinite stream (24×7 mp3 stream).
It hangs for just a few seconds on this call which I have neatly tucked into my startPlaying() method.
The button doesn’t show it’s getting clicked until after the stream starts playing so at first the user is left wondering if they tapped the button or missed.
So I want to update a TextView label next to the button that says “Wait…” or “Buffering” etc. then clear it after the stream starts so the user knows they pressed the button OK.
Even if I step through this in debug the label doesn’t update until after the onClick is finished. I can comment out the last line that clears the label text and can see it set to “Buffering…” OK. But only after it exits the onClick. Is this a limitation of using the media player create() method?

final Button startbutton = (Button) findViewById(R.id.Button01);
this.tvBuffering = (TextView) findViewById(R.id.tvBuffering);

startbutton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            tvBuffering.setText("Buffering...");
            //do something like invalidate() here??
            startPlaying();  //blocks here for a few seconds to buffer then plays.
            tvBuffering.setText(" "); //clear the text since it's playing by now.
        }   
    });
  • 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-24T07:56:58+00:00Added an answer on May 24, 2026 at 7:56 am

    It’s not such a great idea to intentionally include that sort of delay in the UI, because that will block just about anything the user tries to do for those few seconds. I’m assuming that your startPlaying() includes a call to prepare(), as well as start(). When taking data from a source that won’t be immediately available (such as a stream), you should use prepareAsync() instead, which will start preparation and return immediately instead of blocking until preparation is complete.

    You can attach a callback to your MediaPlayer to then take action once preparation has completed through a MediaPlayer.OnPreparedListener

    Here’s a simple example. Note that your OnClickListener can stay the same, as long as you change the prepare() in the startPlaying() method to prepareAsync() and remove the start() call from startPlaying().

    startbutton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            tvBuffering.setText("Buffering...");
    
            startPlaying();  //which should call prepareAsync() instead of prepare()
                             //and have no call to start()
        }   
    });
    
    mYourMediaPlayer.setOnPreparedListener( new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            start();
            tvBuffering.setText(" ");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create a PhoneGap app using the canvas tag on an iPad. The
I am trying to create a Music Player App in J2ME. I want to
well I'm trying to create a great playlist of music, only using a sigle
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
i am trying to create music major scale converter. Dose anyone have info how
I'm trying to create a shell script that runs a command and plays music
I'm trying to create an interface for a launcher app that can be traversed
So I am trying to create a RTSP server that streams music. I do
I am trying to write the interface for my music manager using GTK+. The

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.