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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:19:26+00:00 2026-06-15T15:19:26+00:00

The docs for MediaStream ‘s method prepareAsync() says: Prepares the player for playback, asynchronously.

  • 0

The docs for MediaStream‘s method prepareAsync() says:

Prepares the player for playback, asynchronously. After setting the
datasource and the display surface, you need to either call prepare()
or prepareAsync(). For streams, you should call prepareAsync(),
which returns immediately
, rather than blocking until enough data
has been buffered.

What bad can go wrong if we use prepare() for playing streams? I’ve been using prepare() and I never got into any troubles.

On contrary, in my own case, when I use ‘prepareAsync()’, the stream does NOT start ever. When I use ‘prepare()’ the stream starts after buffering period (1s-2s) and plays well. Why is this happening with async method? Is the form for async prepare the same as for prepare()?

    mPlayer = new MediaPlayer();
    mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mPlayer.setDataSource(STREAM_URL);
    mPlayer.prepareAsync();
    mPlayer.start();
  • 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-15T15:19:28+00:00Added an answer on June 15, 2026 at 3:19 pm

    Doing complex operations in the UI thread is a bad practice. It can block your UI for a long time and Android may kill your app.
    In this case, the prepare() method can take a lot of time due to decoding and fetching data.

    You should call the prepareAsync() method while listening the OnPrepared event. When the event is triggered you should notify your UI and start the player.

    mPlayer = new MediaPlayer();
    mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mPlayer.setDataSource(STREAM_URL);
    mplayer.setOnPreparedListener(/*your listener here*/)
    mPlayer.prepareAsync();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Official docs says : If the object has a method named __dir__() , this
java docs says: A pool of strings, initially empty, is maintained privately by the
http://docs.python.org/3.0/whatsnew/3.0.html says it lists whats new , but in my opinion, it only lists
The docs for WorldPay are really difficult for me to understand after reading and
https://docs.oracle.com/javase/6/docs/api/java/lang/System.html#currentTimeMillis() says: Returns the current time in milliseconds. Note that while the unit of
Docs on creating your database tables says: Another option is to use the init_command
Java Docs says that, putIfAbsent is equivalent to if (!map.containsKey(key)) return map.put(key, value); else
Python docs says that slicing a list returns a new list. Now if a
The docs says i could only execute the crawl command inside the project dir
The docs says that ancestor will apply a filter of given ancestor being somewhere

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.