在Ionic 3上录制和播放音频 [英] Recording and playing back audio on Ionic 3

查看:624
本文介绍了在Ionic 3上录制和播放音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS上遇到了一个奇怪的问题。

I am having a weird issue on iOS.

我正在使用Ionic Native Media插件录制音频并尝试使用HTML5 Web Audio播放录音API(WavesurferJS或HowlerJS)。
我录制音频后,如果我立即播放录音,音频将无法播放,但如果我关闭应用程序然后重新打开它,音频将播放正常。

I am using the Ionic Native Media plugin to record audio and trying to play the recording back using the HTML5 Web Audio API (WavesurferJS or HowlerJS). After I record the audio if I try to play the recording back immediately the audio will not play, but if I close the app and then re-open it, the audio will play fine.

HowlerJS抛出的错误是解码音频时出错。我的想法是Native Media插件还没有完全释放文件,因此没有授权HowlerJS读取音频数据。

The error that HowlerJS is throwing is "error decoding the audio." My thoughts are the Native Media plugin has not fully released the file, thus not giving permissions to HowlerJS to read the audio data.

任何想法或方向都值得赞赏。

Any thoughts or direction is appreciated.

推荐答案

使用Cordova插件媒体:

Use Cordova Plugin Media :

$ ionic cordova plugin add cordova-plugin-media
$ npm install --save @ionic-native/media

来自离子doc的有用文章:

Useful article from ionic doc :

https://ionicframework.com/docs/native/media/

这篇关于在Ionic 3上录制和播放音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆