Thank u so much for the reply but The program does not work even after changing....
Thank you for much for the reply....Can you please help me.. On Feb 9, 12:04 pm, Dave Sparks <davidspa...@android.com> 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 <ashwin.disco...@gmail.com> 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 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.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---