【发布时间】:2018-03-01 21:08:56
【问题描述】:
我在 Ionic 中创建了一个简单的应用程序,它使用 Native Audio 来播放单个 MP3 文件。代码:
export class MyApp{
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private nativeAudio:NativeAudio) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
this.nativeAudio.preloadComplex('24', 'assets/klamydihahaha.mp3',1,1,0.1).then(
(data)=>{
alert(data);
this.nativeAudio.play('24',()=>{alert("done")});
},(error)=>{
alert(error);
}
)
});
}
}
我在装有 Android 6.0 的 Sony Xperia 设备上使用
ionic cordova run android --device
警报消息将首先显示“ok”,它会等待,然后显示“done”消息。但是没有声音。 MP3 文件工作正常。可能是什么问题?
【问题讨论】: