Put javascript blob variable in src of audio - Stack Overflow

In my javascript code I create a url from my audio blobvar blobUrl = URL.createObjectURL(blob);I then h

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
Add a ment  | 

1 Answer 1

Reset to default 3

You 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

相关推荐

  • Put javascript blob variable in src of audio - Stack Overflow

    In my javascript code I create a url from my audio blobvar blobUrl = URL.createObjectURL(blob);I then h

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信