[android-developers] Re: Playing video in android

2009-02-15 Thread Dave Sparks

Are you looking at the log in DDMS? There must be some log output
associated with your application. At the very least, you should see
ActivityManager starting and stopping it.

You can also add some logging to your code.

import android.util.Log;
private static final String TAG = "MyProgram";

Then scatter log statements around the code in various places:

Log.d(TAG, "This will output to the log");

On Feb 14, 11:28 pm, Ash  wrote:
> thanx for reply... the above code after making changes as mentioned by
> Dave Sparks
> does not show any error...  when i found the application in emulator
> and run it myself...
> i jus see a black screen for a second  and the program exits
>
> Can u pls help me in correcting the code or by any other video display
> code...
> thank u so much for support and replies...
>
> On Feb 14, 1:05 pm, Dave Sparks  wrote:
>
> > We can't help you if you can't describe the errors you are seeing.
> > What is in the log?
>
> > On Feb 14, 10:01 am, Ash  wrote:
>
> > > Thank u so much for the reply but The program does Not execute at
> > > all.. Can u please help
>
> > > On Feb 9, 2:53 am, Dilli  wrote:
>
> > > >  Hi
>
> > > >  i think you fixed the size ofvideodisplay
>
> > > > >>  mHolder.setFixedSize(176, 144);
>
> > > >   it may cause the problem of  videodisplaying
>
> > > >  use   mHolder.setFixedSize(mp.getVideoWidth(),
> > > > mp.getVideoHeight());
>
> > > >  Regards
>
> > > > On Feb 9, 3:58 am, Ash  wrote:
>
> > > > > Playvideoonandroid
> > > > > -
>
> > > > > I'm trying toplayvideofiles onandroid...can anyone please help
> > > > > me...
> > > > > I'm not able to see thevideobut audio works fine... here is the code
>
> > > > > PLEASE HELP ME... BY GUIDING ME.. BY CORRECTING THE CODE
> > > > > OR WITH ANY NEW CODE
>
> > > > > package com.vi3;
>
> > > > > import java.io.IOException;
> > > > > importandroid.app.Activity;
> > > > > importandroid.os.Bundle;
> > > > > importandroid.content.Context;
> > > > > importandroid.graphics.PixelFormat;
> > > > > importandroid.media.MediaPlayer;
> > > > > importandroid.media.MediaPlayer.OnBufferingUpdateListener;
> > > > > importandroid.media.MediaPlayer.OnCompletionListener;
> > > > > importandroid.media.MediaPlayer.OnErrorListener;
> > > > > importandroid.util.Log;
> > > > > importandroid.view.Menu;
> > > > > importandroid.view.SurfaceHolder;
> > > > > importandroid.view.SurfaceView;
> > > > > importandroid.view.Surface;
> > > > > importandroid.view.Window;
> > > > > //importandroid.view.Menu.Item;
>
> > > > > public class vi3 extends Activity
> > > > > {
> > > > >private static final String LOG_TAG = "|";
> > > > >private MediaPlayer mp;
>
> > > > >private Preview mPreview;
> > > > >//private myAcListener myListener = new myAcListener()this;
> > > > >/** Called when the activity is first created. */
> > > > >@Override
> > > > >public void onCreate(Bundle icicle)
> > > > >{
> > > > >   super.onCreate(icicle);
> > > > >   Log.i(LOG_TAG, "CameraApp.onCreate");
> > > > >   mPreview = new Preview(this);
> > > > >   //requestWindowFeature(W);
>
> > > > > //  stopMedia();
> > > > >// releaseMedia();
> > > > >   setContentView(R.layout.main);
>
> > > > >   //setContentView(mPreview);
> > > > >   playMedia("");
>
> > > > >}
>
> > > > >private void playMedia(String s_filePath)
> > > > >{
> > > > >   setContentView(mPreview);
> > > > >   //s_filePath = "/tmp/mp4.mp4";
> > > > >   s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";
> > > > >   //s_filePath = "/tmp/test.mpg";
> > > > >   //s_filePath = "/tmp/3.3gp";
> > > > >   Log.i(LOG_TAG, "CameraApp.playMedia");
> > > > >   mp = new MediaPlayer();
> > > > >   try
> > > > >   {
> > > > >  mp.setDataSource(s_filePath);
> > > > >   }
> > > > >   catch (IllegalArgumentException e)
> > > > >   {
> > > > >  // TODO Auto-generated catch block
> > > > >  Log.v(LOG_TAG,
> > > > > "CameraApp.playMedia:IllegalArgumentException");
> > > > >  e.printStackTrace();
> > > > >   }
> > > > >   catch (IOException e)
> > > > >   {
> > > > >  Log.v(LOG_TAG, "CameraApp.playMedia:IOException");
> > > > >  // TODO Auto-generated catch block
> > > > >  e.printStackTrace();
> > > > >   }
> > > > >   try
> > > > >   {
>
> > > > >  //mp.setDisplay(mPreview.getHolder().getSurface());
> > > > >  mp.prepare();
> > > > >  int i = mp.getDuration();
> > > > >  Log.i(LOG_TAG, "Duration:" + String.valueOf(i));
> > > > >  mp.start();
> > > > >   }
> > > > >   catch (Exception e)
> > > > >   {
> > > > >  Log.v(LOG_TAG, e.toString());
> > > > >  mp.stop();
> > > > >  mp.release();
> > > > >   }
> > > > >   //setContentView(mPreview);
> > > > >}
>
> >

[android-developers] Re: Playing video in android

2009-02-14 Thread Ash

thanx for reply... the above code after making changes as mentioned by
Dave Sparks
does not show any error...  when i found the application in emulator
and run it myself...
i jus see a black screen for a second  and the program exits

Can u pls help me in correcting the code or by any other video display
code...
thank u so much for support and replies...

On Feb 14, 1:05 pm, Dave Sparks  wrote:
> We can't help you if you can't describe the errors you are seeing.
> What is in the log?
>
> On Feb 14, 10:01 am, Ash  wrote:
>
> > Thank u so much for the reply but The program does Not execute at
> > all.. Can u please help
>
> > On Feb 9, 2:53 am, Dilli  wrote:
>
> > >  Hi
>
> > >  i think you fixed the size ofvideodisplay
>
> > >     >>  mHolder.setFixedSize(176, 144);
>
> > >   it may cause the problem of  videodisplaying
>
> > >  use   mHolder.setFixedSize(mp.getVideoWidth(),
> > > mp.getVideoHeight());
>
> > >  Regards
>
> > > On Feb 9, 3:58 am, Ash  wrote:
>
> > > > Playvideoonandroid
> > > > -
>
> > > > I'm trying toplayvideofiles onandroid...can anyone please help
> > > > me...
> > > > I'm not able to see thevideobut audio works fine... here is the code
>
> > > > PLEASE HELP ME... BY GUIDING ME.. BY CORRECTING THE CODE
> > > > OR WITH ANY NEW CODE
>
> > > > package com.vi3;
>
> > > > import java.io.IOException;
> > > > importandroid.app.Activity;
> > > > importandroid.os.Bundle;
> > > > importandroid.content.Context;
> > > > importandroid.graphics.PixelFormat;
> > > > importandroid.media.MediaPlayer;
> > > > importandroid.media.MediaPlayer.OnBufferingUpdateListener;
> > > > importandroid.media.MediaPlayer.OnCompletionListener;
> > > > importandroid.media.MediaPlayer.OnErrorListener;
> > > > importandroid.util.Log;
> > > > importandroid.view.Menu;
> > > > importandroid.view.SurfaceHolder;
> > > > importandroid.view.SurfaceView;
> > > > importandroid.view.Surface;
> > > > importandroid.view.Window;
> > > > //importandroid.view.Menu.Item;
>
> > > > public class vi3 extends Activity
> > > > {
> > > >    private static final String LOG_TAG = "|";
> > > >    private MediaPlayer mp;
>
> > > >    private Preview mPreview;
> > > >    //private myAcListener myListener = new myAcListener()this;
> > > >    /** Called when the activity is first created. */
> > > >   �...@override
> > > >    public void onCreate(Bundle icicle)
> > > >    {
> > > >       super.onCreate(icicle);
> > > >       Log.i(LOG_TAG, "CameraApp.onCreate");
> > > >       mPreview = new Preview(this);
> > > >       //requestWindowFeature(W);
>
> > > >     //  stopMedia();
> > > >        //     releaseMedia();
> > > >       setContentView(R.layout.main);
>
> > > >       //setContentView(mPreview);
> > > >       playMedia("");
>
> > > >    }
>
> > > >    private void playMedia(String s_filePath)
> > > >    {
> > > >       setContentView(mPreview);
> > > >       //s_filePath = "/tmp/mp4.mp4";
> > > >       s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";
> > > >       //s_filePath = "/tmp/test.mpg";
> > > >       //s_filePath = "/tmp/3.3gp";
> > > >       Log.i(LOG_TAG, "CameraApp.playMedia");
> > > >       mp = new MediaPlayer();
> > > >       try
> > > >       {
> > > >          mp.setDataSource(s_filePath);
> > > >       }
> > > >       catch (IllegalArgumentException e)
> > > >       {
> > > >          // TODO Auto-generated catch block
> > > >          Log.v(LOG_TAG,
> > > > "CameraApp.playMedia:IllegalArgumentException");
> > > >          e.printStackTrace();
> > > >       }
> > > >       catch (IOException e)
> > > >       {
> > > >          Log.v(LOG_TAG, "CameraApp.playMedia:IOException");
> > > >          // TODO Auto-generated catch block
> > > >          e.printStackTrace();
> > > >       }
> > > >       try
> > > >       {
>
> > > >          //mp.setDisplay(mPreview.getHolder().getSurface());
> > > >          mp.prepare();
> > > >          int i = mp.getDuration();
> > > >          Log.i(LOG_TAG, "Duration:" + String.valueOf(i));
> > > >          mp.start();
> > > >       }
> > > >       catch (Exception e)
> > > >       {
> > > >          Log.v(LOG_TAG, e.toString());
> > > >          mp.stop();
> > > >          mp.release();
> > > >       }
> > > >       //setContentView(mPreview);
> > > >    }
>
> > > >    private void pauseMedia()
> > > >    {
> > > >       Log.i(LOG_TAG, "CameraApp.pauseMedia");
> > > >       if (null != mp)
> > > >       {
> > > >          mp.pause();
> > > >       }
> > > >    }
>
> > > >    private void stopMedia()
> > > >    {
> > > >       Log.i(LOG_TAG, "CameraApp.stopMedia");
> > > >       if (null != mp)
> > > >       {
> > > >          mp.stop();
> > > >       }
> > > >    }
> > > >    private void releaseMedia()
> > > >    {
> > > >       Log.i(LOG_TAG, "CameraApp.releaseMedia");
> > > >       if (null != mp)
> > > >       {
> > > >          mp.release();
> > > >       }
> > > >    }
> > > >    class Preview exte

[android-developers] Re: Playing video in android

2009-02-14 Thread Marco Nelissen
>  s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";


This is probably not going to work, since playback is actually handled by a
different process, which probably doesn't have permissions to access that
file. The preferred way of handling this is to get a FileDescriptor for the
file in question, and then using the version of MediaPlayer.setDataSource()
that takes a file descriptor.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Playing video in android

2009-02-14 Thread Dave Sparks

We can't help you if you can't describe the errors you are seeing.
What is in the log?

On Feb 14, 10:01 am, Ash  wrote:
> Thank u so much for the reply but The program does Not execute at
> all.. Can u please help
>
> On Feb 9, 2:53 am, Dilli  wrote:
>
> >  Hi
>
> >  i think you fixed the size ofvideodisplay
>
> > >>  mHolder.setFixedSize(176, 144);
>
> >   it may cause the problem of  videodisplaying
>
> >  use   mHolder.setFixedSize(mp.getVideoWidth(),
> > mp.getVideoHeight());
>
> >  Regards
>
> > On Feb 9, 3:58 am, Ash  wrote:
>
> > > Playvideoonandroid
> > > -
>
> > > I'm trying toplayvideofiles onandroid...can anyone please help
> > > me...
> > > I'm not able to see thevideobut audio works fine... here is the code
>
> > > PLEASE HELP ME... BY GUIDING ME.. BY CORRECTING THE CODE
> > > OR WITH ANY NEW CODE
>
> > > package com.vi3;
>
> > > import java.io.IOException;
> > > importandroid.app.Activity;
> > > importandroid.os.Bundle;
> > > importandroid.content.Context;
> > > importandroid.graphics.PixelFormat;
> > > importandroid.media.MediaPlayer;
> > > importandroid.media.MediaPlayer.OnBufferingUpdateListener;
> > > importandroid.media.MediaPlayer.OnCompletionListener;
> > > importandroid.media.MediaPlayer.OnErrorListener;
> > > importandroid.util.Log;
> > > importandroid.view.Menu;
> > > importandroid.view.SurfaceHolder;
> > > importandroid.view.SurfaceView;
> > > importandroid.view.Surface;
> > > importandroid.view.Window;
> > > //importandroid.view.Menu.Item;
>
> > > public class vi3 extends Activity
> > > {
> > >private static final String LOG_TAG = "|";
> > >private MediaPlayer mp;
>
> > >private Preview mPreview;
> > >//private myAcListener myListener = new myAcListener()this;
> > >/** Called when the activity is first created. */
> > >@Override
> > >public void onCreate(Bundle icicle)
> > >{
> > >   super.onCreate(icicle);
> > >   Log.i(LOG_TAG, "CameraApp.onCreate");
> > >   mPreview = new Preview(this);
> > >   //requestWindowFeature(W);
>
> > > //  stopMedia();
> > >// releaseMedia();
> > >   setContentView(R.layout.main);
>
> > >   //setContentView(mPreview);
> > >   playMedia("");
>
> > >}
>
> > >private void playMedia(String s_filePath)
> > >{
> > >   setContentView(mPreview);
> > >   //s_filePath = "/tmp/mp4.mp4";
> > >   s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";
> > >   //s_filePath = "/tmp/test.mpg";
> > >   //s_filePath = "/tmp/3.3gp";
> > >   Log.i(LOG_TAG, "CameraApp.playMedia");
> > >   mp = new MediaPlayer();
> > >   try
> > >   {
> > >  mp.setDataSource(s_filePath);
> > >   }
> > >   catch (IllegalArgumentException e)
> > >   {
> > >  // TODO Auto-generated catch block
> > >  Log.v(LOG_TAG,
> > > "CameraApp.playMedia:IllegalArgumentException");
> > >  e.printStackTrace();
> > >   }
> > >   catch (IOException e)
> > >   {
> > >  Log.v(LOG_TAG, "CameraApp.playMedia:IOException");
> > >  // TODO Auto-generated catch block
> > >  e.printStackTrace();
> > >   }
> > >   try
> > >   {
>
> > >  //mp.setDisplay(mPreview.getHolder().getSurface());
> > >  mp.prepare();
> > >  int i = mp.getDuration();
> > >  Log.i(LOG_TAG, "Duration:" + String.valueOf(i));
> > >  mp.start();
> > >   }
> > >   catch (Exception e)
> > >   {
> > >  Log.v(LOG_TAG, e.toString());
> > >  mp.stop();
> > >  mp.release();
> > >   }
> > >   //setContentView(mPreview);
> > >}
>
> > >private void pauseMedia()
> > >{
> > >   Log.i(LOG_TAG, "CameraApp.pauseMedia");
> > >   if (null != mp)
> > >   {
> > >  mp.pause();
> > >   }
> > >}
>
> > >private void stopMedia()
> > >{
> > >   Log.i(LOG_TAG, "CameraApp.stopMedia");
> > >   if (null != mp)
> > >   {
> > >  mp.stop();
> > >   }
> > >}
> > >private void releaseMedia()
> > >{
> > >   Log.i(LOG_TAG, "CameraApp.releaseMedia");
> > >   if (null != mp)
> > >   {
> > >  mp.release();
> > >   }
> > >}
> > >class Preview extends SurfaceView implements
> > > SurfaceHolder.Callback
> > >{
> > >SurfaceHolder   mHolder;
> > >private boolean mHasSurface;
> > >Preview(Context context) {
> > >super(context);
>
> > >mHolder = getHolder();
> > >mHolder.addCallback(this);
> > >mHasSurface = false;
>
> > >//mHolder.setFixedSize(320, 240);
> > >mHolder.setFixedSize(176, 144);
> > >//mHolder.setFixedSize(192, 242);
> > >}
>
> > >public void surfaceCreated(SurfaceHolder holder) {
> > >// The Surface has been created, start our main acquisi

[android-developers] Re: Playing video in android

2009-02-14 Thread Ash

Thank u so much for the reply but The program does not work even
after changing

Thank you for much for the replyCan you please help me..


On Feb 9, 12:04 pm, Dave Sparks  wrote:
> First, the surface type needs to be push buffers. In your Preview
> constructor, add the following:
>
>     getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>
> Second, you need to tell the media player where to display thevideo.
> You have a line commented out:
>
>     //mp.setDisplay(mPreview.getHolder().getSurface());
>
> It should look like this:
>
>     mp.setDisplay(mPreview.getHolder());
>
> If you get stuck, take a look at the VideoView.java widget source code
> on android.git.kernel.org. It's in the frameworks/base project at core/
> java/widget/VideoView.java
>
> On Feb 8, 2:58 pm, Ash  wrote:
>
> > Playvideoon android
> > -
>
> > I'm trying to playvideofiles on android...can anyone please help
> > me...
> > I'm not able to see thevideobut audio works fine... here is the code
>
> > PLEASE HELP ME... BY GUIDING ME.. BY CORRECTING THE CODE
> > OR WITH ANY NEW CODE
>
> > package com.vi3;
>
> > import java.io.IOException;
> > import android.app.Activity;
> > import android.os.Bundle;
> > import android.content.Context;
> > import android.graphics.PixelFormat;
> > import android.media.MediaPlayer;
> > import android.media.MediaPlayer.OnBufferingUpdateListener;
> > import android.media.MediaPlayer.OnCompletionListener;
> > import android.media.MediaPlayer.OnErrorListener;
> > import android.util.Log;
> > import android.view.Menu;
> > import android.view.SurfaceHolder;
> > import android.view.SurfaceView;
> > import android.view.Surface;
> > import android.view.Window;
> > //import android.view.Menu.Item;
>
> > public class vi3 extends Activity
> > {
> >    private static final String LOG_TAG = "|";
> >    private MediaPlayer mp;
>
> >    private Preview mPreview;
> >    //private myAcListener myListener = new myAcListener()this;
> >    /** Called when the activity is first created. */
> >   �...@override
> >    public void onCreate(Bundle icicle)
> >    {
> >       super.onCreate(icicle);
> >       Log.i(LOG_TAG, "CameraApp.onCreate");
> >       mPreview = new Preview(this);
> >       //requestWindowFeature(W);
>
> >     //  stopMedia();
> >        //     releaseMedia();
> >       setContentView(R.layout.main);
>
> >       //setContentView(mPreview);
> >       playMedia("");
>
> >    }
>
> >    private void playMedia(String s_filePath)
> >    {
> >       setContentView(mPreview);
> >       //s_filePath = "/tmp/mp4.mp4";
> >       s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";
> >       //s_filePath = "/tmp/test.mpg";
> >       //s_filePath = "/tmp/3.3gp";
> >       Log.i(LOG_TAG, "CameraApp.playMedia");
> >       mp = new MediaPlayer();
> >       try
> >       {
> >          mp.setDataSource(s_filePath);
> >       }
> >       catch (IllegalArgumentException e)
> >       {
> >          // TODO Auto-generated catch block
> >          Log.v(LOG_TAG,
> > "CameraApp.playMedia:IllegalArgumentException");
> >          e.printStackTrace();
> >       }
> >       catch (IOException e)
> >       {
> >          Log.v(LOG_TAG, "CameraApp.playMedia:IOException");
> >          // TODO Auto-generated catch block
> >          e.printStackTrace();
> >       }
> >       try
> >       {
>
> >          //mp.setDisplay(mPreview.getHolder().getSurface());
> >          mp.prepare();
> >          int i = mp.getDuration();
> >          Log.i(LOG_TAG, "Duration:" + String.valueOf(i));
> >          mp.start();
> >       }
> >       catch (Exception e)
> >       {
> >          Log.v(LOG_TAG, e.toString());
> >          mp.stop();
> >          mp.release();
> >       }
> >       //setContentView(mPreview);
> >    }
>
> >    private void pauseMedia()
> >    {
> >       Log.i(LOG_TAG, "CameraApp.pauseMedia");
> >       if (null != mp)
> >       {
> >          mp.pause();
> >       }
> >    }
>
> >    private void stopMedia()
> >    {
> >       Log.i(LOG_TAG, "CameraApp.stopMedia");
> >       if (null != mp)
> >       {
> >          mp.stop();
> >       }
> >    }
> >    private void releaseMedia()
> >    {
> >       Log.i(LOG_TAG, "CameraApp.releaseMedia");
> >       if (null != mp)
> >       {
> >          mp.release();
> >       }
> >    }
> >    class Preview extends SurfaceView implements
> > SurfaceHolder.Callback
> >    {
> >        SurfaceHolder   mHolder;
> >        private boolean         mHasSurface;
> >        Preview(Context context) {
> >            super(context);
>
> >            mHolder = getHolder();
> >            mHolder.addCallback(this);
> >            mHasSurface = false;
>
> >            //mHolder.setFixedSize(320, 240);
> >            mHolder.setFixedSize(176, 144);
> >            //mHolder.setFixedSize(192, 242);
> >        }
>
> >        public void surfaceCreated(SurfaceHolder holder) {
> >            // The Surface has been created, start our

[android-developers] Re: Playing video in android

2009-02-14 Thread Ash

Thank u so much for the reply but The program does Not execute at
all.. Can u please help

On Feb 9, 2:53 am, Dilli  wrote:
>  Hi
>
>  i think you fixed the size ofvideodisplay
>
>     >>  mHolder.setFixedSize(176, 144);
>
>   it may cause the problem of  videodisplaying
>
>  use   mHolder.setFixedSize(mp.getVideoWidth(),
> mp.getVideoHeight());
>
>  Regards
>
> On Feb 9, 3:58 am, Ash  wrote:
>
> > Playvideoonandroid
> > -
>
> > I'm trying toplayvideofiles onandroid...can anyone please help
> > me...
> > I'm not able to see thevideobut audio works fine... here is the code
>
> > PLEASE HELP ME... BY GUIDING ME.. BY CORRECTING THE CODE
> > OR WITH ANY NEW CODE
>
> > package com.vi3;
>
> > import java.io.IOException;
> > importandroid.app.Activity;
> > importandroid.os.Bundle;
> > importandroid.content.Context;
> > importandroid.graphics.PixelFormat;
> > importandroid.media.MediaPlayer;
> > importandroid.media.MediaPlayer.OnBufferingUpdateListener;
> > importandroid.media.MediaPlayer.OnCompletionListener;
> > importandroid.media.MediaPlayer.OnErrorListener;
> > importandroid.util.Log;
> > importandroid.view.Menu;
> > importandroid.view.SurfaceHolder;
> > importandroid.view.SurfaceView;
> > importandroid.view.Surface;
> > importandroid.view.Window;
> > //importandroid.view.Menu.Item;
>
> > public class vi3 extends Activity
> > {
> >    private static final String LOG_TAG = "|";
> >    private MediaPlayer mp;
>
> >    private Preview mPreview;
> >    //private myAcListener myListener = new myAcListener()this;
> >    /** Called when the activity is first created. */
> >   �...@override
> >    public void onCreate(Bundle icicle)
> >    {
> >       super.onCreate(icicle);
> >       Log.i(LOG_TAG, "CameraApp.onCreate");
> >       mPreview = new Preview(this);
> >       //requestWindowFeature(W);
>
> >     //  stopMedia();
> >        //     releaseMedia();
> >       setContentView(R.layout.main);
>
> >       //setContentView(mPreview);
> >       playMedia("");
>
> >    }
>
> >    private void playMedia(String s_filePath)
> >    {
> >       setContentView(mPreview);
> >       //s_filePath = "/tmp/mp4.mp4";
> >       s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";
> >       //s_filePath = "/tmp/test.mpg";
> >       //s_filePath = "/tmp/3.3gp";
> >       Log.i(LOG_TAG, "CameraApp.playMedia");
> >       mp = new MediaPlayer();
> >       try
> >       {
> >          mp.setDataSource(s_filePath);
> >       }
> >       catch (IllegalArgumentException e)
> >       {
> >          // TODO Auto-generated catch block
> >          Log.v(LOG_TAG,
> > "CameraApp.playMedia:IllegalArgumentException");
> >          e.printStackTrace();
> >       }
> >       catch (IOException e)
> >       {
> >          Log.v(LOG_TAG, "CameraApp.playMedia:IOException");
> >          // TODO Auto-generated catch block
> >          e.printStackTrace();
> >       }
> >       try
> >       {
>
> >          //mp.setDisplay(mPreview.getHolder().getSurface());
> >          mp.prepare();
> >          int i = mp.getDuration();
> >          Log.i(LOG_TAG, "Duration:" + String.valueOf(i));
> >          mp.start();
> >       }
> >       catch (Exception e)
> >       {
> >          Log.v(LOG_TAG, e.toString());
> >          mp.stop();
> >          mp.release();
> >       }
> >       //setContentView(mPreview);
> >    }
>
> >    private void pauseMedia()
> >    {
> >       Log.i(LOG_TAG, "CameraApp.pauseMedia");
> >       if (null != mp)
> >       {
> >          mp.pause();
> >       }
> >    }
>
> >    private void stopMedia()
> >    {
> >       Log.i(LOG_TAG, "CameraApp.stopMedia");
> >       if (null != mp)
> >       {
> >          mp.stop();
> >       }
> >    }
> >    private void releaseMedia()
> >    {
> >       Log.i(LOG_TAG, "CameraApp.releaseMedia");
> >       if (null != mp)
> >       {
> >          mp.release();
> >       }
> >    }
> >    class Preview extends SurfaceView implements
> > SurfaceHolder.Callback
> >    {
> >        SurfaceHolder   mHolder;
> >        private boolean         mHasSurface;
> >        Preview(Context context) {
> >            super(context);
>
> >            mHolder = getHolder();
> >            mHolder.addCallback(this);
> >            mHasSurface = false;
>
> >            //mHolder.setFixedSize(320, 240);
> >            mHolder.setFixedSize(176, 144);
> >            //mHolder.setFixedSize(192, 242);
> >        }
>
> >        public void surfaceCreated(SurfaceHolder holder) {
> >            // The Surface has been created, start our main acquisition
> > thread.
> >            mHasSurface = true;
> >        }
>
> >        public void surfaceDestroyed(SurfaceHolder holder) {
> >            // Surface will be destroyed when we return. Stop the
> > preview.
> >            mHasSurface = false;
> >        }
>
> >        public void surfaceChanged(SurfaceHolder holder, int format,int
> > w, int h) {
> >            // Surface size or format

[android-developers] Re: Playing video in android

2009-02-09 Thread Dave Sparks

First, the surface type needs to be push buffers. In your Preview
constructor, add the following:

getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

Second, you need to tell the media player where to display the video.
You have a line commented out:

//mp.setDisplay(mPreview.getHolder().getSurface());

It should look like this:

mp.setDisplay(mPreview.getHolder());

If you get stuck, take a look at the VideoView.java widget source code
on android.git.kernel.org. It's in the frameworks/base project at core/
java/widget/VideoView.java

On Feb 8, 2:58 pm, Ash  wrote:
> Play video on android
> -
>
> I'm trying to play video files on android...can anyone please help
> me...
> I'm not able to see the video but audio works fine... here is the code
>
> PLEASE HELP ME... BY GUIDING ME.. BY CORRECTING THE CODE
> OR WITH ANY NEW CODE
>
> package com.vi3;
>
> import java.io.IOException;
> import android.app.Activity;
> import android.os.Bundle;
> import android.content.Context;
> import android.graphics.PixelFormat;
> import android.media.MediaPlayer;
> import android.media.MediaPlayer.OnBufferingUpdateListener;
> import android.media.MediaPlayer.OnCompletionListener;
> import android.media.MediaPlayer.OnErrorListener;
> import android.util.Log;
> import android.view.Menu;
> import android.view.SurfaceHolder;
> import android.view.SurfaceView;
> import android.view.Surface;
> import android.view.Window;
> //import android.view.Menu.Item;
>
> public class vi3 extends Activity
> {
>private static final String LOG_TAG = "|";
>private MediaPlayer mp;
>
>private Preview mPreview;
>//private myAcListener myListener = new myAcListener()this;
>/** Called when the activity is first created. */
>@Override
>public void onCreate(Bundle icicle)
>{
>   super.onCreate(icicle);
>   Log.i(LOG_TAG, "CameraApp.onCreate");
>   mPreview = new Preview(this);
>   //requestWindowFeature(W);
>
> //  stopMedia();
>// releaseMedia();
>   setContentView(R.layout.main);
>
>   //setContentView(mPreview);
>   playMedia("");
>
>}
>
>private void playMedia(String s_filePath)
>{
>   setContentView(mPreview);
>   //s_filePath = "/tmp/mp4.mp4";
>   s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";
>   //s_filePath = "/tmp/test.mpg";
>   //s_filePath = "/tmp/3.3gp";
>   Log.i(LOG_TAG, "CameraApp.playMedia");
>   mp = new MediaPlayer();
>   try
>   {
>  mp.setDataSource(s_filePath);
>   }
>   catch (IllegalArgumentException e)
>   {
>  // TODO Auto-generated catch block
>  Log.v(LOG_TAG,
> "CameraApp.playMedia:IllegalArgumentException");
>  e.printStackTrace();
>   }
>   catch (IOException e)
>   {
>  Log.v(LOG_TAG, "CameraApp.playMedia:IOException");
>  // TODO Auto-generated catch block
>  e.printStackTrace();
>   }
>   try
>   {
>
>  //mp.setDisplay(mPreview.getHolder().getSurface());
>  mp.prepare();
>  int i = mp.getDuration();
>  Log.i(LOG_TAG, "Duration:" + String.valueOf(i));
>  mp.start();
>   }
>   catch (Exception e)
>   {
>  Log.v(LOG_TAG, e.toString());
>  mp.stop();
>  mp.release();
>   }
>   //setContentView(mPreview);
>}
>
>private void pauseMedia()
>{
>   Log.i(LOG_TAG, "CameraApp.pauseMedia");
>   if (null != mp)
>   {
>  mp.pause();
>   }
>}
>
>private void stopMedia()
>{
>   Log.i(LOG_TAG, "CameraApp.stopMedia");
>   if (null != mp)
>   {
>  mp.stop();
>   }
>}
>private void releaseMedia()
>{
>   Log.i(LOG_TAG, "CameraApp.releaseMedia");
>   if (null != mp)
>   {
>  mp.release();
>   }
>}
>class Preview extends SurfaceView implements
> SurfaceHolder.Callback
>{
>SurfaceHolder   mHolder;
>private boolean mHasSurface;
>Preview(Context context) {
>super(context);
>
>mHolder = getHolder();
>mHolder.addCallback(this);
>mHasSurface = false;
>
>//mHolder.setFixedSize(320, 240);
>mHolder.setFixedSize(176, 144);
>//mHolder.setFixedSize(192, 242);
>}
>
>public void surfaceCreated(SurfaceHolder holder) {
>// The Surface has been created, start our main acquisition
> thread.
>mHasSurface = true;
>}
>
>public void surfaceDestroyed(SurfaceHolder holder) {
>// Surface will be destroyed when we return. Stop the
> preview.
>mHasSurface = false;
>}
>
>public void surfaceChanged(SurfaceHolder holder, int format,int
> w, int h) {
>// Surface size or format has changed. This should not
> happen   in this
>// example.
>

[android-developers] Re: Playing video in android

2009-02-09 Thread Dilli



 Hi

 i think you fixed the size of video display

>>  mHolder.setFixedSize(176, 144);

  it may cause the problem of  video displaying


 use   mHolder.setFixedSize(mp.getVideoWidth(),
mp.getVideoHeight());


 Regards


On Feb 9, 3:58 am, Ash  wrote:
> Playvideoonandroid
> -
>
> I'm trying toplayvideofiles onandroid...can anyone please help
> me...
> I'm not able to see thevideobut audio works fine... here is the code
>
> PLEASE HELP ME... BY GUIDING ME.. BY CORRECTING THE CODE
> OR WITH ANY NEW CODE
>
> package com.vi3;
>
> import java.io.IOException;
> importandroid.app.Activity;
> importandroid.os.Bundle;
> importandroid.content.Context;
> importandroid.graphics.PixelFormat;
> importandroid.media.MediaPlayer;
> importandroid.media.MediaPlayer.OnBufferingUpdateListener;
> importandroid.media.MediaPlayer.OnCompletionListener;
> importandroid.media.MediaPlayer.OnErrorListener;
> importandroid.util.Log;
> importandroid.view.Menu;
> importandroid.view.SurfaceHolder;
> importandroid.view.SurfaceView;
> importandroid.view.Surface;
> importandroid.view.Window;
> //importandroid.view.Menu.Item;
>
> public class vi3 extends Activity
> {
>    private static final String LOG_TAG = "|";
>    private MediaPlayer mp;
>
>    private Preview mPreview;
>    //private myAcListener myListener = new myAcListener()this;
>    /** Called when the activity is first created. */
>   �...@override
>    public void onCreate(Bundle icicle)
>    {
>       super.onCreate(icicle);
>       Log.i(LOG_TAG, "CameraApp.onCreate");
>       mPreview = new Preview(this);
>       //requestWindowFeature(W);
>
>     //  stopMedia();
>        //     releaseMedia();
>       setContentView(R.layout.main);
>
>       //setContentView(mPreview);
>       playMedia("");
>
>    }
>
>    private void playMedia(String s_filePath)
>    {
>       setContentView(mPreview);
>       //s_filePath = "/tmp/mp4.mp4";
>       s_filePath =  "/data/local/video/test_qcif_200_aac_64.mp4";
>       //s_filePath = "/tmp/test.mpg";
>       //s_filePath = "/tmp/3.3gp";
>       Log.i(LOG_TAG, "CameraApp.playMedia");
>       mp = new MediaPlayer();
>       try
>       {
>          mp.setDataSource(s_filePath);
>       }
>       catch (IllegalArgumentException e)
>       {
>          // TODO Auto-generated catch block
>          Log.v(LOG_TAG,
> "CameraApp.playMedia:IllegalArgumentException");
>          e.printStackTrace();
>       }
>       catch (IOException e)
>       {
>          Log.v(LOG_TAG, "CameraApp.playMedia:IOException");
>          // TODO Auto-generated catch block
>          e.printStackTrace();
>       }
>       try
>       {
>
>          //mp.setDisplay(mPreview.getHolder().getSurface());
>          mp.prepare();
>          int i = mp.getDuration();
>          Log.i(LOG_TAG, "Duration:" + String.valueOf(i));
>          mp.start();
>       }
>       catch (Exception e)
>       {
>          Log.v(LOG_TAG, e.toString());
>          mp.stop();
>          mp.release();
>       }
>       //setContentView(mPreview);
>    }
>
>    private void pauseMedia()
>    {
>       Log.i(LOG_TAG, "CameraApp.pauseMedia");
>       if (null != mp)
>       {
>          mp.pause();
>       }
>    }
>
>    private void stopMedia()
>    {
>       Log.i(LOG_TAG, "CameraApp.stopMedia");
>       if (null != mp)
>       {
>          mp.stop();
>       }
>    }
>    private void releaseMedia()
>    {
>       Log.i(LOG_TAG, "CameraApp.releaseMedia");
>       if (null != mp)
>       {
>          mp.release();
>       }
>    }
>    class Preview extends SurfaceView implements
> SurfaceHolder.Callback
>    {
>        SurfaceHolder   mHolder;
>        private boolean         mHasSurface;
>        Preview(Context context) {
>            super(context);
>
>            mHolder = getHolder();
>            mHolder.addCallback(this);
>            mHasSurface = false;
>
>            //mHolder.setFixedSize(320, 240);
>            mHolder.setFixedSize(176, 144);
>            //mHolder.setFixedSize(192, 242);
>        }
>
>        public void surfaceCreated(SurfaceHolder holder) {
>            // The Surface has been created, start our main acquisition
> thread.
>            mHasSurface = true;
>        }
>
>        public void surfaceDestroyed(SurfaceHolder holder) {
>            // Surface will be destroyed when we return. Stop the
> preview.
>            mHasSurface = false;
>        }
>
>        public void surfaceChanged(SurfaceHolder holder, int format,int
> w, int h) {
>            // Surface size or format has changed. This should not
> happen   in this
>            // example.
>        }
>    }
>
> }

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.