Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know the Duration of audio song before streaming?

I am making an application for Stream audio song. In Custom media player, i have to show the total duration of that audio file. If a audio song will be SDCard , i can know its duration using

MediaPlayer player;

public double duration() {
        return player.getDuration();
    }

But in my case audio file is on the server, so i have to stream it.

What is the best approach?

like image 289
Gaurav Gupta Avatar asked Aug 10 '11 09:08

Gaurav Gupta


1 Answers

This might help you: Example of Streaming mp3 with android media player class . The respective data is probably available, once prepare() is called for the file to be streamed.

like image 115
SamSPICA Avatar answered Nov 15 '22 03:11

SamSPICA