maxwellgover
maxwellgover

Reputation: 7151

Passing Blob to new Audio

I'm trying to create an audio element using new Audio(). The data I get back from Dropbox contains an object w/ a fileBlob property

fileBlob: Blob(5498932)
  size: 5498932
  type: "application/octet-stream"
  __proto__: Blob

How can I get this into a format that can be passed to new Audio()?

Upvotes: 0

Views: 279

Answers (2)

Tom M
Tom M

Reputation: 2904

According to the HTMLAudioElement-Documentation, expects a URLString.

For that, you can use createObjectURL

new Audio(URL.createObjectURL(fileBlob))

Upvotes: 1

maxwellgover
maxwellgover

Reputation: 7151

const blobUrl = URL.createObjectURL(downloadPath.fileBlob);

Seems to work

Upvotes: 1

Related Questions