admin管理员组文章数量:1417108
In my javascript code I create a url from my audio blob
var blobUrl = URL.createObjectURL(blob);
I then have an audio controller. How do I put the blobUrl variable into the src = ?
<audio controls="controls">
<source src= blobUrl type="audio/mp3">
</audio>
In my javascript code I create a url from my audio blob
var blobUrl = URL.createObjectURL(blob);
I then have an audio controller. How do I put the blobUrl variable into the src = ?
<audio controls="controls">
<source src= blobUrl type="audio/mp3">
</audio>
Share
Improve this question
asked May 23, 2014 at 0:01
SolidCloudincSolidCloudinc
32111 silver badges27 bronze badges
1 Answer
Reset to default 3You need to get the source
element and set its src
property.
Lets get the element using the basic js DOM API.
var srcElement = document.getElementsByTagName("source")[0]; // Assuming there's only one
Now lets set the src
property using
srcElement.src = blobUrl;
or srcElement.setAttribute("src", blobUrl);
or jquery's element.attr()
method if you get the element using a jquery selector.
本文标签: Put javascript blob variable in src of audioStack Overflow
版权声明:本文标题:Put javascript blob variable in src of audio - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745241336a2649345.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论