I'm in the middle of creating a Sound provider for button taps and background game music. In My Sound provider called sound.ts I'm using the NativeAudio plugin and have defined a function for preloading my sound data. But when I'm building my app with
ionic run android -c
I get the following Error message:
ngc: Error: Property 'preloadSimple' does not exist on type 'NativeAudio'.
sound.ts
import { Injectable } from '@angular/core';
import { NativeAudio } from 'ionic-native';
...
@Injectable()
export class Sound {
constructor(
public nativeAudio : NativeAudio
){}
loadSounds(){
return this.nativeAudio.preloadSimple('buttonTick', 'assets/sounds/button-tick.wav')
.then(()=>{
return Promise.resolve("loaded sounds successfully");
})
.catch(this.handleError);
}
...
In my app.component.ts I'm firing the loadSounds() method of my Sound provider
app.component.ts
import ... // Config/Sound/...
...
constructor(
public platform : Platform,
public config : Config,
public sound : Sound
){
platform.ready().then(() => {
// loading config & sounds
config.loadDefault()
.then(msg => {
console.log(msg);
return sound.loadSounds(); <----------(HERE)
})
.then(msg => {
console.log(msg);
})
.catch(err => {
...
My app.module.ts injects the NativeAudio provider and my custom Sound provider. So I come to question if there is something wrong with the plugin for rc0 or if I miss something ?
Do I have to declare NativeAudio somehow, and how do I declare a plugin in my povider .ts file ? because I guess this is a typescript error ...
I solved this problem, the reason the error came where because of using NativeAudio (from ionic/native) like a non native module.
constructor(
public nativeAudio : NativeAudio <---- HAD TO DELETE THIS
){}
and afterwards I shouldnt use "this" in front of NativeAudio