Howler.js: How to play ogg from blob?

Created on 19 Oct 2015  路  4Comments  路  Source: goldfire/howler.js

Hi,

I am encoding to ogg via the users mic. The encoder returns a blob.

I am able to play this back if I do the following with an Audio object as so:

var url = URL.createObjectURL( oggBlob );
var audio = new Audio();
audio.src = url;
audio.play();

_OR_

<Audio src='blob:http://localhost/address_to_blob' />

The above plays just fine, but if I try to use Howler to play this same blob I can't get it to work.

var url = URL.createObjectURL( oggBlob );
var sound = new Howl({
  urls: [url]
}).play();

Doesn't work

I've also tried some other variations on the above

var url = URL.createObjectURL( oggBlob );
var sound = new Howl({
  autoplay: true
});
sound.src = url;

Any ideas? Is there something weird when using a blob like this?

Thanks

Most helpful comment

Just an FYI for anyone that is looking at this later as reference, ext has been changed back to format.

All 4 comments

Same issue here

You can specify the extension:

var sound = new Howl({
  src: [url],
  ext: ['ogg']
});

And then howler will be able to check if the ogg format is supported in the browser.

Right, you need to specify the ext so that it knows what kind of audio is trying to be played.

Just an FYI for anyone that is looking at this later as reference, ext has been changed back to format.

Was this page helpful?
0 / 5 - 0 ratings