Playing audio with Cascades
You can use the MediaPlayer to play audio files and streams. The MediaPlayer allows your app to play audio files, and also provides your app with seek, rewind, and fast forward functionality.
You can create one MediaPlayer for every sound you want to play, but it's not necessary unless you intend to play more than one sound at the same time. You can use one MediaPlayer and programmatically set its sourceUrl property for each sound that you want to play, at the moment that you're ready to play that sound.
Depending on the resources that are available to the device that will run your app, you could choose to create a MediaPlayer for each sound you want to play. This allows you to call the prepare() function for each MediaPlayer in advance and acquire the resources needed to play each sound. You may want to do this if you need to play a number of sounds in rapid succession, or if you want to play many sounds at the same time. The trade-off is that your app holds a number of resources as it prepares itself to play all of the sounds, in all of the MediaPlayer objects that have been defined. This may cause the device to fail if it doesn't have a sufficient amount of resources to support the app's demands. Whether you choose to create one or many MediaPlayer objects for your app should be judged on a case-by-case basis.
Last modified: 2015-07-24