399
Chapter 11
Digital Video: Streaming
Video, MediaPlayer, and
MediaController classes
In the previous chapter on 2D Animation, we covered implementing motion graphics in Android and
using digital image file formats such as PNG or JPEG in conjunction with XML constructs to create
frame-based animation.
There is another way that you can play a series of frames in Android, called “digital video.” Digital
video assets are especially well-suited for situations when you have hundreds or even thousands of
frames, and cannot easily handle them all using an Android AnimationDrawable class. Additionally,
digital video can be “streamed” over a network connection, which 2D animation assets cannot, and
thus your new media can be external to your application.
In this chapter, we are going to take all of the newfound knowledge that you gained in Chapter 10
regarding the fourth dimension (or 4D) of time, as well as concepts that you learned about such as
frames and frame rates, and we’ll again expand upon that knowledge, with new concepts such as
bitrates and new digital video codec (file format) support in Android, including the popular MPEG-4
and Web-M digital video formats which are also the formats that are used in HTML5.
We’ll be covering several often-utilized Android classes you can use to implement video graphic
design elements, such as the VideoView UI widget, a FrameLayout UI layout container, as well
as three media-related Android classes which you can utilize to implement digital video (or digital
audio) control and playback. These include the MediaPlayer (video or audio playback), Uri, and the
MediaController (the transport control panel).
During this chapter, we will be utilizing these five Android digital video-related UI design
(FrameLayout and VideoView) and playback (MediaPlayer, Uri, and MediaController) classes to
create a digital video playback Activity for your application. We’ll install a VideoView UI widget in a