离子3从录制的文件中获取base64音频字符串 [英] Ionic 3 get base64 audio string from recorded file

查看:196
本文介绍了离子3从录制的文件中获取base64音频字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 cordova-plugin-media 录制语音(具有暂停和恢复功能)功能)在适用于Android的离子应用中.记录后,我需要获取base64字符串才能使用html音频标签播放它.问题是:如果我要保存已暂停并恢复为3gp文件('voice.3gp')的记录,那么当我使用

I am using cordova-plugin-media to record voice(with pause and resume features) in my ionic app for android. After I record it I need to get base64 string in order to play it using html audio tag. And the problem is: if I am trying to save recording which was paused and resumed as 3gp file('voice.3gp'), then when I use readAsDataURL method of cordova-plugin-file, I don't receive anything(the callback simply not called). If I am trying to save it as mp3 or wav file, then I receive only 1st part of the recording(before pause). I suppose that the proper audio file extension should be 3gp as this extension is used in the implementation of 'cordova-plugin-media' but then I have problems with playing this file using html audio tag. Any help is appriciated

推荐答案

阅读: https ://ionicionicworkwork.com/docs/v3/native/base64/

这是ionic的官方网站API.只需安装该插件并使用:

It is the oficial website API of ionic. Just install that plugin and use this:

 this.base64.encodeFile(this.filePath + this.fileName).then(
      (base64:any) =>{
      console.log('file base64 encoding: ' + base64);
    });

在这篇文章中,我会更好地解释.我让链接在这里: 在ionic 3中将音频文件转换为base64

In this post, i explain it better. I let the link here: convert audio file to base64 in ionic 3

这篇关于离子3从录制的文件中获取base64音频字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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