# Native Audio Problem

**URL:** <https://forum.ionicframework.com/t/native-audio-problem/97738>\
**Category:** Ionic Native\
**Created:** [July 11, 2017, 1:22pm UTC](https://forum.ionicframework.com/t/native-audio-problem/97738 "2017-07-11T13:22:21Z")\
**Posts on this page:** 8\
**Page:** 2

<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:** [July 12, 2017, 6:49pm UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/21 "2017-07-12T18:49:25Z")

</div>

No idea, I am working from the docs here, but it probably doesn’t hurt if you unload something that isn’t even there, it just will not do anything and maybe go into the error callback (if you decide to handle that).

---

<div class="post-metadata">

**Author:** ![dimitri320](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dimitri320/32/116022_2.png) [@dimitri320](https://forum.ionicframework.com/u/dimitri320)\
**Post date:** [September 29, 2017, 11:00am UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/22 "2017-09-29T11:00:42Z")

</div>

For me this doesn’t work. doesn’t give any errors, just does produce any sound at all! I’m using the exact same code! Any ideas what might be off?

---

<div class="post-metadata">

**Author:** ![xixiao](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xixiao/32/109989_2.png) [@xixiao](https://forum.ionicframework.com/u/xixiao)\
**Post date:** [October 9, 2017, 8:41pm UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/23 "2017-10-09T20:41:37Z")

</div>

Me too, the native-audio plguin seems failing in iOS 10.

Here people said “using preloadComplex instead of preloadSimple” as a walk around [https://github.com/floatinghotpot/cordova-plugin-nativeaudio/issues/100](https://github.com/floatinghotpot/cordova-plugin-nativeaudio/issues/100)

---

<div class="post-metadata">

**Author:** ![dimitri320](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dimitri320/32/116022_2.png) [@dimitri320](https://forum.ionicframework.com/u/dimitri320)\
**Post date:** [October 11, 2017, 2:11pm UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/24 "2017-10-11T14:11:53Z")

</div>

I’m tried both on iOS11 and it doesn’t work. The only workaround I found was to load the audio file into memory, so that the App wouldn’t have to download it.

---

<div class="post-metadata">

**Author:** ![newBeat](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@newBeat](https://forum.ionicframework.com/u/newBeat)\
**Post date:** [February 26, 2018, 6:41am UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/25 "2018-02-26T06:41:27Z")

</div>

Hi @Sujan12!

Can I play audio from one page and stop from the same audio from another page. If yes please can you tell me how to do it?

---

<div class="post-metadata">

**Author:** ![Darksideous](https://avatars.discourse-cdn.com/v4/letter/d/6bbea6/32.png) [@Darksideous](https://forum.ionicframework.com/u/Darksideous)\
**Post date:** [September 9, 2018, 1:12am UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/26 "2018-09-09T01:12:02Z")

</div>

> [@xixiao](#):
>
> [No sound on iOS 10 anymore (9.x is OK) · Issue #100 · floatinghotpot/cordova-plugin-nativeaudio · GitHub](https://github.com/floatinghotpot/cordova-plugin-nativeaudio/issues/100)

Hi Dimitri can you show me an example of you preloading into memory mine is failing as well

```auto
import {Injectable} from "@angular/core";
import {Platform} from "ionic-angular";
import {NativeAudio} from "@ionic-native/native-audio";

@Injectable()
export class SmartAudio {

  audioType: string = 'html5';
  sounds: any = [];

  constructor(public nativeAudio: NativeAudio, platform: Platform) {

    if (platform.is('cordova')) {
      this.audioType = 'native';
    }

  }

  preload(key, asset) {

    if (this.audioType === 'html5') {

      let audio = {
        key: key,
        asset: asset,
        type: 'html5'
      };

      this.sounds.push(audio);

    } else {

      this.nativeAudio.preloadSimple(key, asset);

      let audio = {
        key: key,
        asset: key,
        type: 'native'
      };

      this.sounds.push(audio);
    }

  }

  play(key) {

    let audio = this.sounds.find((sound) => {
      return sound.key === key;
    });

    if (audio.type === 'html5') {

      let audioAsset = new Audio(audio.asset);
      audioAsset.play();

    } else {

      this.nativeAudio.play(audio.asset).then((res) => {
        console.log(res);
      }, (err) => {
        console.log(err);
      });

    }

  }

}

```

and my app.component.ts

```auto
platform.ready().then(() => {

      platform.registerBackButtonAction(() => this.myHandlerFunction());

      StatusBar.hide();
      smartAudio.preload('menuSlide', 'assets/audio/menuSlide.wav');
      smartAudio.preload('onDrop', 'assets/audio/onDrop1.wav');
      smartAudio.preload('onPickUp', 'assets/audio/onPickUP1.wav');
      smartAudio.preload('onSwipe', 'assets/audio/onSlideGuess3.wav');
      smartAudio.preload('opponentAlert', 'assets/audio/opponentALert1.wav');
      smartAudio.preload('infoClick', 'assets/audio/onInfoClick.wav');
      smartAudio.preload('HomeChalkIntro', 'assets/audio/writing on chalkboard Intro.wav');
      smartAudio.preload('YouWonner', 'assets/audio/FunTime.wav');
      smartAudio.preload('tilesTumble', 'assets/audio/tilesTumble.wav');
      smartAudio.preload('challengerAlarm', 'assets/audio/alarma.wav');

    });
  }

```

---

<div class="post-metadata">

**Author:** ![sansopheakh](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sansopheakh/32/133068_2.png) [@sansopheakh](https://forum.ionicframework.com/u/sansopheakh)\
**Post date:** [July 13, 2020, 2:50pm UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/27 "2020-07-13T14:50:36Z")

</div>

> [@Sujan12](#):
>
> ```auto
> ionViewDidLoad() {
> this.platform.ready().then(() => {	
> this.nativeAudio.preloadComplex('uniqueKey1', 'assets/audio/merhaba.mp3', 1, 1, 0).then(() => {     
> this.nativeAudio.play('uniqueKey1');
> });
> });
> }
> 
> ```

I have follow this code on my app home.page.ts but it’s not work. It’s not play and not show any error. 😢

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 8:54pm UTC](https://forum.ionicframework.com/t/native-audio-problem/97738/28 "2021-07-19T20:54:25Z")

</div>

Closed on July 19, 2021, 8:54pm UTC



[Previous page](https://forum.ionicframework.com/t/native-audio-problem/97738.md?page=1)
