Try printing your argument to data source and see if it is proper. Also you
can first try playing a 3gp/mp4 file present on the sdcard  to see if some
video is being played or not.

On Thu, Jan 21, 2010 at 9:03 AM, rukiman <[email protected]> wrote:

> That was how I had it originally, I tried again but still doesn't work
>
> On Jan 21, 2:18 pm, kavitha sunil <[email protected]> wrote:
> > try using
> >
> > mediaplayer.setDisplay(videoSurfaceHolder[0]);
> >
>  > On Thu, Jan 21, 2010 at 8:39 AM, rukiman <[email protected]>
> wrote:
> > > Attached is my code, I cannot see the video while playing a MPG file.
> > > What am I doing wrong here? Thanks.
> >
> > > public class VideoTest extends Activity implements
> > > SurfaceHolder.Callback{
> >
> > >    private ArrayList<MediaPlayer> mMediaVideoPlayers = new
> > > ArrayList<MediaPlayer>();
> > >    private SurfaceView videoSurface[] = new SurfaceView[4];
> > >    private SurfaceHolder videoSurfaceHolder[] = new SurfaceHolder[4];
> >
> > >    @Override
> > >    public void onCreate(Bundle savedInstanceState) {
> > >        super.onCreate(savedInstanceState);
> > >        setContentView(R.layout.main);
> > >        videoSurface[0] = (SurfaceView)findViewById(R.id.video1);
> > >        videoSurfaceHolder[0] = videoSurface[0].getHolder();
> > >        videoSurfaceHolder[0].addCallback(this);
> > >        videoSurfaceHolder[0].setType
> > > (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
> > >    }
> >
> > >    private void playVideo(int res, SurfaceHolder holder) {
> > >        MediaPlayer mediaplayer = new MediaPlayer();
> > >        AssetFileDescriptor afd = getResources().openRawResourceFd
> > > (res);
> > >        try {
> > >            mediaplayer.setDataSource(afd.getFileDescriptor(),
> > > afd.getStartOffset(), afd.getLength());
> > >            mediaplayer.setDisplay(holder);
> > >            mediaplayer.prepare();
> > >            mediaplayer.start();
> > >            mMediaVideoPlayers.add(mediaplayer);
> > >        } catch (IllegalArgumentException e) {
> > >            e.printStackTrace();
> > >        } catch (IllegalStateException e) {
> > >            e.printStackTrace();
> > >        } catch (IOException e) {
> > >            e.printStackTrace();
> > >        }
> > >    }
> >
> > >    public void surfaceChanged(SurfaceHolder holder, int format, int
> > > width, int height) {
> > >    }
> >
> > >    public void surfaceCreated(SurfaceHolder holder) {
> > >        playVideo(R.raw.video2, holder);
> > >    }
> >
> > >    public void surfaceDestroyed(SurfaceHolder holder) {
> > >    }
> > > }
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
>  > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to