I'm trying to load local audio file by the (input:file) Elem and when I passe it to the audio constructor Audio() as an object it doesn't load/play.
file Object params&meths:
lastModified: 1586969070000
lastModifiedDate: Wed Apr 15 2020 18:44:30 GMT+0200 (Central European Summer Time) {}
name: "audio.mp3"
size: 15235482
type: "audio/mpeg"
webkitRelativePath: ""
i tried giving just the name, relative path but nothing seems to work.
Js Code
var track = new Audio(file Object);
track.play();
when I tried to troubleshoot:
console.log(track);
<audio preload="auto" src="[object File]">
#shadow-root (user-agent)
</audio>
and when play() triggered:
GET http:// **Local IP** /[object%20File] 404 (Not Found)
index.html:1 Uncaught (in promise) DOMException: Failed to load because no supported source was found.
although before I started the project I did a little test and it worked perfectly but now it doesn't... any help will be amazing thanks
var track = new Audio(file Object);- wrong way. You must insert URL into new Audio constructor, not file Object