From the course: Android Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Play an audio file from assets

Play an audio file from assets - Android Tutorial

From the course: Android Development Tips

Play an audio file from assets

- [Narrator] The Android SDK media player component can be used to play both audio and video content. It can play from a web-based resource with a URL, but can also be used to play local files stored on the device. When you package an app and include an audio file, one of the most common places to include it is in the assets folder. This is a folder under the application module which can contain arbitrary files of any format. These files aren't associated with a resource ID and the media player component can't play an audio or video file directly from this folder. In order to use it, you have to copy it to the device's file system, usually to internal or external storage. I'm going to demonstrate this using this beginning app where I've included an MP3 file in the assets directory. I'm going to open this file in Explorer on Windows, or you can do this in Finder on Mac, and I'll double-click and play it. So my goal is to copy that MP3 file to internal storage and then play it with the…

Contents