ok i thought I would try the ApiDemo that comes with android.
what path should I put in here? Is "/sdcard/video2.mpg" correct as
that is where I have placed video2.mpg. However even ApiDemo doesn't
play the video it comes up with the same error.
W/MediaPlayer( 750): info/warning (1, 26)
E/PlayerDriver( 31): Command PLAYER_SET_DATA_SOURCE completed with
an error or info PVMFErrNotSupported
E/MediaPlayer( 750): error (1, -4)
E/MediaPlayerDemo( 750): error: Prepare failed.: status=0x1
E/MediaPlayerDemo( 750): java.io.IOException: Prepare failed.:
status=0x1
E/MediaPlayerDemo( 750): at android.media.MediaPlayer.prepare(Native
Method)
E/MediaPlayerDemo( 750): at
com.example.android.apis.media.MediaPlayerDemo_Video.playVideo
(MediaPlayerDemo_Video.java:125)
E/MediaPlayerDemo( 750): at
com.example.android.apis.media.MediaPlayerDemo_Video.surfaceCreated
(MediaPlayerDemo_Video.java:181)
E/MediaPlayerDemo( 750): at android.view.SurfaceView.updateWindow
(SurfaceView.java:454)
E/MediaPlayerDemo( 750): at android.view.SurfaceView.dispatchDraw
(SurfaceView.java:287)
E/MediaPlayerDemo( 750): at android.view.ViewGroup.drawChild
(ViewGroup.java:1524)
E/MediaPlayerDemo( 750): at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1256)
/*
* TODO: Set the path variable to a local media
file path.
*/
path = "/sdcard/video2.mpg";
if (path == "") {
// Tell the user to provide a media file URL.
Toast
.makeText(
MediaPlayerDemo_Video.this,
"Please edit
MediaPlayerDemo_Video Activity, "
+ "and set the path
variable to your media file path."
+ " Your media file
must be stored on sdcard.",
Toast.LENGTH_LONG).show();
}
On Jan 21, 3:20 pm, kavitha sunil <[email protected]> wrote:
> 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