# Audio doesn't work in Android

**URL:** <https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848>\
**Category:** ionic-v3\
**Created:** [April 17, 2017, 8:40pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848 "2017-04-17T20:40:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![grandepuffo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grandepuffo/32/108557_2.png) [@grandepuffo](https://forum.ionicframework.com/u/grandepuffo)\
**Post date:** [April 17, 2017, 8:40pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/1 "2017-04-17T20:40:04Z")

</div>

Hi, I’m developing a web app for kids where, when someone press on the “play” button or clicks an image, a sound is heard.

The problem is that while on browser the audio flawlessly, in Android (both emulator and device) I hear nothing.

In my code I used a simple Media plugin, eg:

> ```
> this.media.create('assets/audio/'+this.storia.mainaudio+'.mp3')
> .then((file: MediaObject) => {
> this.audio = file;
> this.audioLoaded = true;
> });
> 
> ```

and in my browser this works perfectly.

When I press the “play” button on my emulator, I hear no sound, I get this from Logcat:

> MediaFocusControl: AudioFocus requestAudioFocus() from uid/pid 10071/5359 clientId=android.media.AudioManager@deb768dorg.apache.cordova.media.AudioHandler$1@96ea042 req=1 flags=0x0

When I press the Pause button , I read:  
AudioPlayer: AudioPlayer Error: pausePlaying() called during invalid state: 0

(I suppose because the audio is not running)

Thanks in advance for any hint.

Antonio

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [April 17, 2017, 8:58pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/2 "2017-04-17T20:58:17Z")

</div>

> [@grandepuffo](#):
>
> this.media

is [https://ionicframework.com/docs/native/media/](https://ionicframework.com/docs/native/media/), right?

---

<div class="post-metadata">

**Author:** ![grandepuffo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grandepuffo/32/108557_2.png) [@grandepuffo](https://forum.ionicframework.com/u/grandepuffo)\
**Post date:** [April 17, 2017, 9:03pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/3 "2017-04-17T21:03:28Z")

</div>

Yes, it is. I’ve followed that usage and in fact it works on my browser

---

<div class="post-metadata">

**Author:** ![grandepuffo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grandepuffo/32/108557_2.png) [@grandepuffo](https://forum.ionicframework.com/u/grandepuffo)\
**Post date:** [April 17, 2017, 11:11pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/4 "2017-04-17T23:11:01Z")

</div>

It looks like I can’t find the right path, I’ve tried a lot of paths but no one gave me the right result. My audio files are stored in assets/audio/, so I tried every possible interpolation:

“assets/audio/”+file  
"/assets/audio/"+file  
"android\_asset/www/assets/audio/"+file  
"/android\_asset/www./assets/audio"+file  
"android\_asset/assets/audio/"+file  
"/android\_asset/assets/audio"+file  
(following this article [https://www.raymondcamden.com/2014/06/23/Cordova-Media-API-Example/](https://www.raymondcamden.com/2014/06/23/Cordova-Media-API-Example/))

Still no result ☹

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [April 17, 2017, 11:22pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/5 "2017-04-17T23:22:12Z")

</div>

Never used this before, but “/android\_asset/www/assets/audio/filename.extension” should work:

> <https://github.com/apache/cordova-plugin-media/blob/cc4d641b9f24643f07263b24a88621367102a188/tests/tests.js#L561>

---

<div class="post-metadata">

**Author:** ![grandepuffo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grandepuffo/32/108557_2.png) [@grandepuffo](https://forum.ionicframework.com/u/grandepuffo)\
**Post date:** [April 17, 2017, 11:26pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/6 "2017-04-17T23:26:17Z")

</div>

Thank you. I’ll give it a try!

---

<div class="post-metadata">

**Author:** ![grandepuffo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grandepuffo/32/108557_2.png) [@grandepuffo](https://forum.ionicframework.com/u/grandepuffo)\
**Post date:** [April 17, 2017, 11:55pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/7 "2017-04-17T23:55:32Z")

</div>

Your answer solved my problem, thank you! By the way, I’ve tried your path more than a year ago, but I’ve now realized that - I don’t know why - my Ionic build doesn’t actually build a new apk file and sometimes it loads the previous version of the file (without the latest modifications I’ve done)…

---

<div class="post-metadata">

**Author:** ![yuricamara](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/yuricamara/32/94528_2.png) [@yuricamara](https://forum.ionicframework.com/u/yuricamara)\
**Post date:** [June 20, 2018, 7:34pm UTC](https://forum.ionicframework.com/t/audio-doesnt-work-in-android/86848/8 "2018-06-20T19:34:55Z")

</div>

Hi Folks,

What’s the path for iOS9+ assets?
