Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

How to Add Audio Files to Android App in Android Studio?

0

Last Updated : 18 Feb, 2021

The audio file format is a file format for saving digital audio information on a pc system and all are conscious of audio information. So on this article, we’re going to focus on how can we add audio information to the android app. There are three main teams of audio file codecs:

Format Name

Description

Examples

Uncompressed audio codecs Uncompressed audio codecs are also referred to as uncooked audio format. RAW Audio format or simply RAW Audio is an audio file format for saving uncompressed audio in uncooked type. Comparable to WAV or AIFF in dimension, the RAW Audio file doesn’t embrace any header info. WAV (Waveform Audio File Format), AIFF (Audio Interchange File Format), and so on.
Formats with lossless compression A lossless compressed audio format saves information in a smaller area with out losing any info. The authentic, uncompressed information may be recreated from the compressed model. FLAC, Monkey’s Audio WavePack, TTA
Formats with lossy compression The lossy audio format permits even larger reductions in file dimension by eliminating among the audio info and simplifying the info. Opus, MP3, Vorbis, Musepack, AAC, ATRAC

Note: Android helps the next audio format

  • MP3
  • MIDI
  • Opus
  • Vorbis
  • PCM/WAVE
  • FLAC
  • AMR-WB
  • AMR-NB and so on.

Step by Step Implementation

Step 1: Open your android studio go to the app > res > right-click > New > Android Resource Directory as proven within the beneath picture. 

Step 2: Then a pop-up display screen will come up like beneath. Here in Resource kind select uncooked.

Step 3: After selecting the uncooked from the dropdown menu click on on the OK button and maintain all of the issues as it’s.

Step 4: Now you may see the uncooked folder has been created and you will discover the folded within the app > res > uncooked as proven within the beneath picture. 

Step 5: After creating the uncooked folder efficiently go to your individual system and copy the required audio information as we do usually. Now once more come again to the android studio and right-click on the uncooked folder. Then click on on the Paste button as proven within the beneath picture.

Step 6: Here on this display screen you may rename your audio file title as your requirement. And click on on the Refactor button. And you’re performed.

Now go to the app > res > uncooked and you will discover your audio file as proven within the beneath determine.

Now open the Java File of the specified exercise, right here we’re including audio within the MainActivity.java file and add this following code within the MainActivity.java file.

Java

MediaPlayer music = MediaPlayer.create(MainActivity.this, R.uncooked.music);

music.begin();

News

Improve

Leave A Reply

Your email address will not be published.