A (175)

(Tuis.) #1

408 CHAPTER 11: Digital Video: Streaming Video, MediaPlayer, and MediaController classes


The VideoView Class: A VideoPlayer Widget


Before we get into all of the complex Java code and XML markup to implement this video player
inside of the FrameLayout container that you have just installed in the HelloUniverse Android
application, I want to get into the VideoView class in detail, so that you have the foundational
knowledge about how all of these classes work.


After that, we will be able to implement this knowledge, and finish coding the XML UI design
definition which will feature a FrameLayout that contains a VideoView. After that, we will take some
time to learn about digital video concepts as they relate to Android and create video using the
Terragen 3.0 virtual world creation software package. After that, we will learn about the MediaPlayer
class and get into some more advanced Java programming.


Android’s VideoView widget class is a direct subclass of the SurfaceView class, which is a direct
subclass of the Android View class, which is a direct subclass of the java.lang.Object master class.
Android’s VideoView class hierarchy is structured as follows:


java.lang.Object



android.view.View
android.view.SurfaceView
android.widget.VideoView



The SurfaceView superclass (View subclass) is similar to the FrameLayout (ViewGroup subclass) in as
much as it is intended to provide a class for creating View widgets that are used for one sole purpose:
playing content on their surface. In the case of the VideoView subclass, this would be playing digital
video content on the surface of the View object, as is evident in the naming of the class.


The Android VideoView class is stored in the android.widget package, making the VideoView a user
interface element, which we know is called a UI widget in Android OS. For this reason, your import
statement for using a VideoView class in an Android application would reference android.widget.
VideoView as its package path.


Figure 11-7. The activity_play.xml FrameLayout UI layout container XML definition file ready for VideoView

Free download pdf