446 CHAPTER 11: Digital Video: Streaming Video, MediaPlayer, and MediaController classes
You learned about Android’s FrameLayout UI layout container class, and how it respects or “locks”
the aspect ratio of your Drawable object asset which it contains, to prevent unwanted skewing or
warping of an asset. You also learned later on in the chapter how to force the Android OS to
non-uniformly scale (to “unlock” the aspect ratio) by using the RelativeLayout layout container
class, in conjunction with the layout_alignParent parameters.
Next, you looked at the FrameLayout.LayoutParams nested class and the concept of layout
gravity and how it is the only way to generally position UI elements inside of a FrameLayout
container, since that layout container type in Android is designed to usually hold only one or maybe
two UI elements. In this chapter, this was your VideoView widget, and eventually a MediaPlayer
transport UI element, called a MediaController.
Next, you created your FrameLayout UI XML definition file, as well as your PlayVideo.java Activity
subclass, so that you had your foundation in place for adding in all of this digital video functionality.
After doing that, you learned about the VideoView class and the video lifecycle stages, and then you
added a VideoView to your FrameLayout. Next, you learned about the Android Uri class and its
Uri.parse( ) method, used to implement the address or “path” to your digital video asset, as well as
to other types of external assets as well, if you wish.
You learned about the foundational concepts of digital video encoding and optimization, including
frame rates, bit-rates, codecs, resolution, quality (blur), and how these all work together to allow
you to optimize your digital video asset’s data footprint. After that, you learned how to use Terragen,
VirtualDub, and Squeeze to create a 3D planet fly over video asset and optimize that asset from full
frames uncompressed AVI format into MPEG-4 file format, taking data that was over 400MB and
turning it into a usable 4MB digital video asset. Amazing stuff!
You finally got around to learning about the Android MediaPlayer class and its eight nested classes,
used for callbacks which allow you to control your user’s digital video experience. You added
an OnPreparedListener( ) event listener to your videoPlayer VideoView object and used the
.setLooping(true) method call, to tell your video asset to loop forever. Then you learned how to alter
a URI so that you were streaming video, instead of using captive video, and finally you implemented
a MediaController object named videoTransport, and wired it up to your videoPlayer VideoView,
using the .setAnchorView( ) and the .setMediaController( ) method calls. You have learned a
plethora of information, tricks, classes, methods, callbacks, and techniques relating to video!
Next, in Chapter12, you’ll learn all about Digital Audio in Android, including foundational digital
audio theory and concepts, what digital audio file formats are optimal to use in Android, and how
to create digital audio assets for use with the Android SoundPool audio sequencing class. More
advanced media concepts and implementation!