0

I want to play video from a URL via HTTP. I read Media Tutorial and other stackoverflow questions. Here is my code:

String url = "http://..../myVideo.mp4"
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
mediaPlayer.start();

mediaPlayer.prepare() is throwing IOException: Prepare failed. For the test purpose I record a video using my mobile phone and then I put the mp4 file to server.

Onuray Sahin
  • 4,093
  • 4
  • 33
  • 34

1 Answers1

0

I missed this line from stack trace:

08-17 14:36:58.005: ERROR/PlayerDriver(1943): Command PLAYER_INIT completed with an error 
                                    or info PVMFErrContentInvalidForProgressivePlayback

The problem is: my video is not capable of progressive download.

The only solution I figured out is using MP4Box which can be downloaded from here.

To make video ready for android I just run MP4Box.exe -hint myVideo.mp4.

Onuray Sahin
  • 4,093
  • 4
  • 33
  • 34