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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745241336a4618199.html
评论列表(0条)