July 2015
Beginner to intermediate
600 pages
18h 59m
English
You have finished all the work for this chapter. You will develop BeatBox to actually use the content of your assets in the next chapter.
Before you do, though, let’s discuss a bit more about how assets work.
Your Sound object has an asset file path defined on it. Asset file paths will not work if you try to open them with a File; you must use them with an AssetManager:
String assetPath = sound.getAssetPath(); InputStream soundData = mAssets.open(assetPath);
This gives you a standard InputStream for the data, which you can use like any other InputStream in Java.
Some APIs require FileDescriptors instead. (This is what you will use with SoundPool in the next chapter.) If you need that, you can call AssetManager.openFd(String) ...
Read now
Unlock full access