The MediaPlayer class that we met in the previous recipe works for video in the same manner that it does for audio and so as not to make this task a near copy of the last, here we will look at how to play back video files stored on an SD card using the VideoView object.
This recipe requires a video file for our application to playback. Android can decode H.263, H.264 and
MPEG-4 files; generally speaking this means files with .3gp
and .mp4
file extensions. For platforms since 3.0 (API level 11) it is also possible to manage H.264 AVC files.
Find a short video clip in one of these compatible formats and save it on the SD card of your handset. Alternatively you can create an emulator with an SD card enabled and push your video file onto it. This can be done easily through Eclipse's DDMS perspective from the File Explorer tab:
In this example we called our video file my_video.3gp
.