I am trying to make an android app that would stream audio from a webserver using http, streaming itself works with VLC and HTML "audio" tag but when trying to stream it using MediaPlayer the file just gets downloaded as a whole, not streamed.
When streamed through VLC/HTML, http response codes are 206(partial data), streaming through MediaPlayer returns 200 every time. File served on the server is in wav format(also tried m4a and mp4)
Code taking care of streaming(basically taken straight from the docs):
String url = "http://localhost:5000/song";
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioAttributes(
new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_MEDIA)
.build()
);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
mediaPlayer.start();