How to play viedo streaming in android

Put your problem here if it does not fit any of the other categories.

How to play viedo streaming in android

Postby swathi » Sat Jun 06, 2009 12:31 pm

I wrote the following code for video streaming in android,But it doesn't work...didn't get any o/p.

public class VideoPlay extends Activity {

private String _videoPath;
private MediaPlayer _mp;
private static final String TAG = "Video";

public void onCreate(Bundle savedInstanceState) {

_videoPath = "";
// _videoPath="";


LinearLayout layout = new LinearLayout(getBaseContext());
layout.setLayoutParams(new LinearLayout.LayoutParams

SurfaceView sview = new SurfaceView(getBaseContext());
sview.setLayoutParams(new LinearLayout.LayoutParams(320,180));
sview.getHolder().addCallback(new surfaceHolderCallback());


class surfaceHolderCallback implements SurfaceHolder.Callback {
public void surfaceCreated(SurfaceHolder holder) {
try {
_mp = new MediaPlayer();

MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mediaPlayer) {

_mp.setOnErrorListener(new MediaPlayer.OnErrorListener
() {
public boolean onError(MediaPlayer mediaPlayer,int
i, int i1) {
Log.e(TAG, Integer.toString(i));
return false;


} catch (Exception ex) {
Log.e(TAG, ex.getMessage());

public void surfaceChanged(SurfaceHolder surfaceHolder, int i,
int i1, int i2) {

public void surfaceDestroyed(SurfaceHolder surfaceHolder) {


can anybody tell me how to do video streaming in android, or is there any mistakes in my code.
Posts: 4
Joined: Tue May 12, 2009 7:39 am


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 24 guests