如何使用base64编码在html5中添加音频 [英] how add audio in html5 with base64 encoding
问题描述
我有一个字符串,它是使用base64编码和wav格式的音频记录(我有数据链接-{{vm.record}}).我需要在可向我播放音频的小部件(用js + html编写)中添加音频播放器
i have a string it is audio record in base64 encoding and in wav format(i have data link - {{vm.record}}). I need add audio player in widget( which had written on js + html) that play audio to me
我不明白为什么它不起作用?我必须在js中写smth才能开始工作吗?在哪里可以写有关编码的内容?
I don't understand why it don't work ? do i must to write smth in js that this start work ? where i can write about encoding ?
<div layout = "row">
<audio
controls
src={{vm.record}} type="audio/wav; base64" autobuffer="autobuffer" autoplay="autoplay">
Your browser does not support the
<code>audio</code> element.
</audio>
</div>
我知道这是错误的"type =" audio/wav;base64",但怎么正确?我尝试了这个,但是也没用
i know that this is wrong "type="audio/wav; base64" but how right? i try this, but it don't work too
<audio controls src="data:audio/ogg;base64,T2dnUwACAAAAAAAAAAAfm5nB6slBlZ3Fcha363d5ut7u3ni1rLoPf728l3KcK"/>
推荐答案
您可以采用base64编码的HTML5 audio
标记,如下所示:
You can have an HTML5 audio
tag in base64 encoding as so:
<audio controls autoplay loop src="data:audio/ogg;base64,BASE64CODE" />
不需要 type
!:)
这篇关于如何使用base64编码在html5中添加音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!