views:

563

answers:

1

I am trying to play video files from http urls in my app. Why is that my app plays only certain mp4 files (I tried 512k mp4 and it worked), and doesn't play some others?

Here's the snippet of my code:

    mVideoView.setVideoPath(myVideoURL);
    mVideoView.setMediaController(new MediaController(this));
    mVideoView.seekTo(currentPosition);
    mVideoView.requestFocus(); 

Thanks Chris

+1  A: 

Make sure your mp4's aren't DRM'd, and that they're not wider than 320 pixels (videoView will not scale them for you). Are you getting any useful errors in LogCat?

Nick Bastin
Here's what LogCat shows me:05-25 21:50:50.498: ERROR/QCOmxcore(51): OMXCORE API : Free Handle fc87c05-25 21:50:50.498: ERROR/QCOmxcore(51): Unloading the dynamic library for OMX.qcom.video.decoder.avc05-25 21:50:50.508: ERROR/PlayerDriver(51): Command PLAYER_PREPARE completed with an error or info PVMFErrNoResources05-25 21:50:50.508: ERROR/MediaPlayer(15981): error (1, -15)05-25 21:50:50.508: ERROR/MediaPlayer(15981): Error (1,-15)How can I make sure to set the VideoView width to 320 pixels?
Chris
It isn't a matter of setting the VideoView width (it is automatically determined by the container its' in) - the actual mp4 video width has to be 320 pixels. You can't play videos larger than 320 pixels wide (you can probably play smaller ones, I'm not sure)
Nick Bastin
So there is no way to play videos larger than 320 pixels on android?
Chris
Not with VideoView (at least at the moment - you gotta figure that's an oversight). This is especially annoying now that some Android phones have screens larger than 320 pixels wide. There may or may not be some newer things in 2.1/2.2/2.x that you could poke around in, but VideoView is basically unchanged since 1.5.
Nick Bastin
I would like my app to be generic, so it can play as many different types of video files as possible, irrespective of size or encoding. Mainly I am looking to play mp4 and 3gp files, buffer/no buffer, stream/no stream etc. What other ways are possible to achieve this, other than VideoView?
Chris
Sadly I don't know of any, but admittedly video isn't my focus. Perhaps if you google around or plumb through the Android docs you might find some other API or library that does video.
Nick Bastin