neildeadman
neildeadman

Reputation: 3969

What format to use for playing video from Internet on Android?

I'm trying to load a video into a VideoView and MediaController with the following code:

video.setVideoURI(Uri.parse(uri));
          
mediaController = new MediaController(this);
mediaController.setMediaPlayer(video);
mediaController.setAnchorView(footer);
video.setMediaController(mediaController);
video.requestFocus();
video.start();

If I use a .3gp file (such as this) it plays. But my MP4 file won't play just bringing up a dialog box saying:

Sorry, this can't play this video

I accept the video may not be in the correct formats for such a purpose as I didn't make it a colleague did. What format should the videos be in?

I use Handbrake usually and am running Ubuntu.

Format Currently:

Video:

Dimensions: 1024 x 624

CODEC: H.264 /AVC

Framerate: 30 frames per second

bitrate: 1307kbps

Audio:

CODEC: MPEG-4 AAC audio

Channels: Stereo

Sample rate: 44100 Hz

Bitrate: 63kbps

Here are some errors from LogCat when playing it as a resource:

12-20 10:54:26.120: I/MediaPlayer(27966): uri is:android.resource://com.android.player/2130968576
12-20 10:54:26.120: I/MediaPlayer(27966): path is null
12-20 10:54:26.160: E/MediaPlayer(27966): Unable to to create media player
12-20 10:54:26.160: D/MediaPlayer(27966): Couldn't open file on client side, trying server side
12-20 10:54:26.160: I/MediaPlayer(27966): prepareAsync called in state 4
12-20 10:54:26.160: E/MediaPlayer(27966): error (1, -2147483648)
12-20 10:54:26.210: E/MediaPlayer(27966): Error (1,-2147483648)
12-20 10:54:26.210: D/VideoView(27966): Error: 1,-2147483648

Upvotes: 1

Views: 1299

Answers (1)

neildeadman
neildeadman

Reputation: 3969

I had one of those light-bulb moments and discovered that the video was hosted on Amazon S3. Uploaded it to our IIS Web Server and it plays!

Upvotes: 0

Related Questions