Reputation: 23558
I'm trying to make an app that plays live http streaming on android (i already did the same in iphone). The Android official tutorial shows a sample code on how to do http live streaming, which i followed:
public class liveStream extends Activity implements OnClickListener {
Button streamButton;
MediaPlayer mediaPlayer = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_live_stream);
streamButton = (Button) findViewById(R.id.streamButton);
streamButton.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_live_stream, menu);
return true;
}
public void onClick(View v) {
String url = "http://d2233avv69kunu.cloudfront.net/hds-live/livepkgr/_definst_/liveevent/livestream.f4m";
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(url);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();
}
}
thing is I keep on getting an IOException when i try to prepare the player.. I did some research and it appears that I will need to play this off a flash client from my android? If that's so, how can I play live http streaming directly without the third party flash player? Similar to iphone
Upvotes: 1
Views: 3902
Reputation: 118
Most android devices from 2.3 on natively support Apple's HLS in some form or another . There are some devices where you'll need to use httplive://.../playlist.m3u8 instead up http://, but as far as I can tell, most devices support an m3u8 URL with just http, especially once you get past Android 3.0
Upvotes: 0
Reputation: 803
Android doesn't support flash manifest file (.f4m) live streaming.
Android supported format for streaming
Upvotes: 2