Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1

Chapter 20  Data Binding and MVVM


So where can you find the sounds? You will be using a Creative Commons-licensed sound set we
initially found provided by the user plagasul at http://www.freesound.org/people/plagasul/packs/3/. We
have put them in a zip file for you at the following location:


http://www.bignerdranch.com/solutions/sample_sounds.zip


Download the zip file and unzip its contents into assets/sample_sounds (Figure 20.5).


Figure 20.5  Imported assets


(Make sure only .wav files are in there, by the way – not the .zip file you got them from.)


Build your app to make sure everything is hunky-dory. The next step will be to list those assets and
show them to the user.


Getting At Assets


BeatBox will end up doing a lot of work related to asset management: finding assets, keeping track of
them, and eventually playing them as sounds. To manage all this, create a new class called BeatBox in
com.bignerdranch.android.beatbox. Go ahead and add a couple of constants: one for logging and
one to remember which folder you saved your wrestling grunts in.


Listing 20.12  New BeatBox class (BeatBox.java)


public class BeatBox {
private static final String TAG = "BeatBox";


private static final String SOUNDS_FOLDER = "sample_sounds";
}

Free download pdf