Better Programming

Advice for programmers.

Follow publication

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

Ng Wai Foong
Better Programming
Published in
4 min readApr 7, 2020

Photo by Josh Sorenson on Unsplash.

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…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Ng Wai Foong
Ng Wai Foong

Written by Ng Wai Foong

Senior AI Engineer@Yoozoo | Content Writer #NLP #datascience #programming #machinelearning | Linkedin: https://www.linkedin.com/in/wai-foong-ng-694619185/

No responses yet

Write a response