Reputation: 521
We are trying to develop an app for Android where you can play a live streaming URL. I can of course play a static MP4 or MP3 file using the URL (hosted on a server) but I am not sure if we can play a live video content from a stream URL. Any thoughts?
How should we go about writing the application to play live video content from a url? Kindly help me.
Upvotes: 1
Views: 1472
Reputation: 631
Try below code to implement the Video Streaming from the server you want.
You need to just give the path of the URL.
path = "http://www.mediaserveryoururl.com/sample.3gp";
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
Upvotes: 1