1

So I have tried 2 things: 1. inserted a MediaPlayer and 2. Inserted a VideoView in my layout, and tried setting the Url of the video.

None have worked, both with an MP4 and FLV file. From what I've read on SO, the videos probably have unsupported encoding or such, and my guess is that I need codecs for them to play.

So naturally, I have these questions:

  1. If I have the MP4 or FLV files, can I check which codecs I need?
  2. Once I know which codecs I need, how would I go about adding them in my app? Are there any open source ones, or do I need to write my own?

Note: Chrome on a PC can run these videos just fine.

Eduard Luca
  • 6,514
  • 16
  • 85
  • 137
  • 1
    First of all for playing unsupported files I suggest you to take a look at FFMPEG library. Most of the Video Players in Play Store are using that library. – hardartcore Jan 18 '13 at 12:48
  • 1
    visit this link http://developer.android.com/guide/appendix/media-formats.html – Priya Jan 18 '13 at 13:19

2 Answers2

2

The problem might be with the video encoding. Android FROYO and Gingerbread doesn't support H264 formats other than "Baseline" H264. So if your video is Mp4 & H264 encoded make sure its "AVC baseline" encoded. Use some tools like "Media info" in windows/Linux and check your video encoding. Convert the video to Baseline if possible.

An alternative workaround is to skip the Videoview and use a video play intent and redirect the playback to an app. User will be prompted to pick a player to handle the playback. Obviously if the video view cant play the file, the default player also wont be able to handle the file. you can choose some other installed player like Mx-Player which will stream the file perfectly.

Ajith M A
  • 3,838
  • 3
  • 32
  • 55
0

The problem why the videos does not played was the phone does not have the supporting video codecs. This is because the video is recorded in some device with specific codec(mpeg4), but that recorded video cannot be played in other devices that does not have that mpeg4 codec. So to overcome this we need to install the missing codec on to the phone. This can be done by

1) Install MX video Player from the Google Play Store

2) This MX Player itself ask the user to install the codec that the phone needs.

3) Click ok to Install the codec from Google play store. Click “install” and click “Accept & Download”

4) Click Keep Shopping button to start download.

5) After download completed. Then click the video file and open it in MX Video Player to play the video.

6) If it ask to upgrade the player, please proceed to install latest MX player using the Google Play Store(proceed step 3,4 and 5)

7) Otherwise video will get played on MX Video Player.

Praveen
  • 231
  • 1
  • 4
  • 13