Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
152
rated 0 times [  157] [ 5]  / answers: 1 / hits: 21326  / 11 Years ago, wed, february 12, 2014, 12:00:00

Is it possible to use an audio file from the user's hard drive as the src attribute for an HTML5 <audio> tag? Maybe through an <input type=file />? This might not be particularly useful in production, but I'm still curious if it can be done.


More From » html5-audio

 Answers
15

I can think of two ways.



Within your audio tag:



src=file:///C:/.../file.mp3


or you could use a Blob using the file API.



HTML:



<input type=file></input>


JS:



audio.src = URL.createObjectURL(document.getElementsByTagName('input')[0].files[0]);

[#72559] Tuesday, February 11, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zaynerogerb

Total Points: 454
Total Questions: 109
Total Answers: 97

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
zaynerogerb questions
;