Hi everyone, I am having the following problem: I am using Android's MediaPlayer to play an mp3 through an HTTP connection. The audio is played correctly, but the MediaPlayer returns an incorrect duration (calling mediaPlayer.getDuration() ). Depending on the mp3 the duration is either shorter or longer.
The code that plays the audio is the following: mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnBufferingUpdateListener(this); mediaPlayer.setDataSource("a valid URL"); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.prepareAsync(); The strange part is that I can reproduce the problem using the default android's music player. If I access the file directly with Android's browser, a simple music player opens up and it show the same wrong duration. If I copy the mp3 directly to the phone and play it directly from there, then it shows the correct duration. The server returns this response: HTTP/1.1 200 OK Date: Thu, 27 May 2010 20:59:48 GMT Content-Type: audio/mpeg Server: aaaaaa Content-Encoding: gzip Transfer-Encoding: chunked Does anyone has a similar problem? Or can anyone give me a clue about what I might be missing to add so the MediaPlayer can fetch the correct duration? Thanks in advance :) -- Demian P. Alonso (demianalo...@gmail.com) -- A conclusion is simply the place where someone got tired of thinking. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en