【问题标题】:Ionic 2 Native Audio No sound on AndroidIonic 2 Native Audio Android 上没有声音
【发布时间】: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 文件工作正常。可能是什么问题?

【问题讨论】:

    标签: android audio ionic2


    【解决方案1】:

    可能是您的命令中未包含cordova API

    请输入此命令

    ionic cordova run android --emulator
    

    ionic cordova emulate android
    

    【讨论】:

      猜你喜欢
      • 2018-10-21
      • 1970-01-01
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-16
      • 1970-01-01
      相关资源
      最近更新 更多