A (175)

(Tuis.) #1
CHAPTER 13: Android Service Class and Threads: Background Processing 501

Click on the Turn Audio On icon on the left and listen to the planet background audio loop play,
as your video loop plays as well. Since these two new media assets do not need to “sync,” you
are now using the VideoView widget, which you learned about and installed in Chapter 11, to play
digital video with one MediaPlayer object. The AmbientService Service subclass, which is using a
second MediaPlayer object, loops your background audio at the same time that your digital video
asset is looping.


If you wanted to sync the audio with the moving frames (moving picture for you film buffs) in the
video, you would use a non-linear digital video editing software tool such as the open source
EditShare Lightworks.


As you can see in the Nexus One AVD emulator, when you click on the Turn Audio On visual icon,
the start Service Intent object is sent to your AmbientService class, and the MediaPlayer starts
playback of your ambient.m4a digital audio asset, so that you have cool background audio special
effects for your planet fly-over experience.


The next thing to test is the Turn Audio Off visual icon on the right side of the video screen, so
click on that next to send a stop Service Intent object to your AmbientService class and stop the
MediaPlayer play back. You should be able to use these two visual icons more than one time, to
start and stop your audio effects as much as you want. Be sure to test this thoroughly and make
sure that your code is working perfectly!


Also notice that when you click on the ImageView UI widgets that are on top of the VideoView UI
widget, the events are “trapped” and are utilized only by those UI elements. They do not affect the
VideoView, so the MediaController does not popup unless you click on the video part of the screen.


Figure 13-18. Use a Nexus One AVD to test your UI designs with padding and wrap_content and margin settings

Free download pdf