I'm using MediaPlayer
to load an mp3 file and play it online. I am using this code:
try{
Log.i("tag1", "try");
mediaPlayer.setDataSource(activity.this, Uri.parse("link"));
mediaPlayer.prepareAsync();
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
Log.i("tag2", "" + mediaPlayer.getDuration());
}
});
} catch(IOException e) {
e.printStackTrace();
}
Most of the times nothing is prepared, so I have the log.i
results as below:
tag1 = try
tag2
is never executed
If, sometimes only, mediaPlayer
is prepared, I get these logs:
tag1 = try
tag2 = 0
_ which is neither acceptable nor usable
Also, when I call mediaPlayer.setOnErrorListener
, I get errors 1,-1004
or 1,-2147483648
. Additionally, mediaPlayer.setOnInfoListener
gives nothing; I think it's never called...
What could be the problem?
It is not unnecessary to mention that in the log folder of the server's file manager, I found this: "stagefright/1.2 (Linux; Android 4.4.4)"
. I think this could help to solve the problem. Also, related to this, can the problem be caused by PHP extensions? if yes, activating which extension solves this issue?
Any help is really appreciated.