Method
prepare () is usually used when we want to play a media file synchronously. prepareAsync () is usually used when we want to play asynchronously.
eg:
mediaplayer.prepare()
Used to play a file from local media resources.
mediaplayer.prepareAsync () is commonly used to play live data in a stream. It allows you to play without blocking the main stream. If we use prepare() to stream data in real time, it will eventually fail because the data is being received in streams. Basically, that prepare() first loads all the data and then plays it back. Thus, it allows you to play media files synchronously. And prepareAsync() plays the data, all that it has in its buffer.
Here are the final quotes
there are two ways (synchronous or asynchronous) that the prepared state can be achieved: either call to prepare () (synchronous), which transfers the object to the ready state after calling the method, or call prepareAsync () (asynchronous), which first transfers the object to the preparation state after the call is returned (which happens almost correctly), while the player’s internal engine continues to work on the rest of the preparation until the preparatory work is completed. When preparation completes or when prepare (), the player’s internal engine then calls the user the callback method, onPrepared () for the OnPreparedListener interface, if OnPreparedListener is registered in advance setOnPreparedListener (android.media.MediaPlayer.OnPreparedListener).
The main difference is that when we use files, we call prepare (), and when we use threads, we call prepareAsync ().
In your case, this should be the prepare () method
Check prepareAsync () and prepare () in the docs clearly indicated
source share