Member-only story
How to Play Audio and Video Files in Your Android App
Use MediaPlayer to control playback of audio/video files and streams

By reading this article, you will learn how to write an audio-playing application that interacts with the user. Based on the official documentation:
“The Android multimedia framework includes support for playing variety of common media types, so that you can easily integrate audio, video and images into your applications. You can play audio or video from media files stored in your application’s resources (raw resources), from standalone files in the filesystem, or from a data stream arriving over a network connection, all using
MediaPlayer
APIs.”
In other words, you can actually use it to play media files such as videos and images. Having said that, this article focuses on playing only audio files as a brief introduction to this API. Feel free to explore further after that.
Let’s get started on your Android project.
1. Setup
Make sure you have installed Android Studio and the necessary SDK before you proceed. Add the following permission for INTERNET
access, as we will be attempting to play both the local and online audios later on:
<uses-permission…