The Android SDK’s MediaPlayer 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 want to include an audio file, one of the most common places to store it is in the assets directory. This directory contains files your app needs, but unlike resources these files aren’t associated with a resource id. Instead, you refer to them by name using the current context and a reference to the app package’s 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 media player component.…
Skill Level Intermediate
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
Building Android Apps with Cloud Serviceswith Albert Lo2h 37m Intermediate
1. Android Development Tips Weekly
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.