10
Description:
I have following code for an Audio player. I can continue Audio playback from any duration by clicking on Progress Bar(between 0-to-mediaplayer.getDuration()). It is working perfectly for Audio playback.
Problem in Audio Streaming:
- When I stream an Audio file from an internet server (say s3-bucket) it starts streaming correctly.
- But mediaPlayer.getDuration() and mediaPlayer.getCurrentPosition() return wrong values. At the beginning of streaming mediaPlayer.getCurrentPosition() returns 5 hours.
- Due to this I am not able to continue Audio streaming from a specified duration of Stream (0-to-Stream Duration).
Questions:
- How can I get the duration of an Audio stream
- How can I continue Audio Streaming from a specified duration. For example for a file of 10-minute duration, I want to start streaming from 6th minute.
Code:
public class MyAudioPlayer extends Activity
implements OnClickListener{
MediaPlayer mediaPlayer = null;
private boolean isPaused=false;
private boolean isStop = true;
String filePath = null;
String productName = null;
ImageButton btnPlay = null;
ImageButton btnPause = null;
ImageButton btnReset = null;
ImageButton btnStop = null;
AudioManager audioManager = null;
SeekBar volControl = null;
SeekBar progressControl = null;
TextView progressText = null;
long durationInMillis = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ltd_audio_player);
volControl = (SeekBar)findViewById(R.id.player_volume);
progressControl = (SeekBar)findViewById(R.id.player_seekbar);
progressText = (TextView) findViewById(R.id.player_progress_text);
btnPlay = (ImageButton) findViewById(R.id.ic_