出了问题!错误代码:1条消息:undefined(媒体插件)

时间:2017-03-04 06:01:39

标签: cordova angular audio ionic2

我的资源文件夹中有一个音频(.mp3)文件,点击按钮我试图使用this plugin播放音频

在我的.ts文件中

export class HomePage {

  constructor(public navCtrl: NavController, public platform:Platform) {
    // const onStatusUpdate = (status) => console.log(status);

    // const file = new MediaPlugin('assets/audio/demo.mp3', onStatusUpdate);
  }

  playAudio(){
   // Create a MediaPlugin instance.  Expects path to file or url as argument
  // We can optionally pass a second argument to track the status of the media
  this.platform.ready().then(()=>{
    const onStatusUpdate = (status) => console.log(status);

    const file = new MediaPlugin('assets/audio/demo.mp3', onStatusUpdate);

    // Catch the Success & Error Output
    // Platform Quirks
    // iOS calls success on completion of playback only
    // Android calls success on completion of playback AND on release()

    file.init.then(() => {
      console.log('Playback Finished');
    }, (err) => {
      console.log('somthing went wrong! error code: ' + err.code + ' message: ' + err.message);
    });

    // play the file
    file.play();
  });
  }
}

我得到了铬的错误://检查

  

出了问题!错误代码:1条消息:未定义

0 个答案:

没有答案
相关问题