1
我正在为按钮水龙头和背景游戏音乐创建声音提供程序。在我的声音提供商叫sound.ts我使用NativeAudio插件,并已定义一个函数预加载我的声音数据。但是,当我建立我的应用程序NativeAudio无法使用离子2 rc0和rc1
ionic run android -c
我收到以下错误消息:
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);
}
...
在我app.component.ts我'正在烧制我的声音提供商的loadSounds()方法
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 => {
...
我app.module.ts注入的NativeAudio提供商和我的自定义声音提供商。 所以我开始质疑rc0的插件是否有问题,或者我错过了什么?
我是否必须以某种方式声明NativeAudio,以及如何在我的povider .ts文件中声明一个插件?因为我猜这是一个打字稿错误...