Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
142
rated 0 times [  146] [ 4]  / answers: 1 / hits: 7393  / 10 Years ago, fri, may 23, 2014, 12:00:00

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>

More From » audio

 Answers
2

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.


[#45102] Thursday, May 22, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
clarkulisesa

Total Points: 422
Total Questions: 93
Total Answers: 112

Location: Austria
Member since Thu, Jan 7, 2021
3 Years ago
clarkulisesa questions
Mon, Feb 24, 20, 00:00, 4 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;