Jump to content

Audio blobURL broken in v3


boyofgreen
 Share

Recommended Posts

Hello Friends,

  I recently upgraded to the RC version of BJS 3 and am now seeing an error that isn't present in v2.  I am creating an audio file and setting the src to a blob URL that I have just created with getUserMedia (it's a wave):

 


var newUrl = (window.URL || window.webkitURL).createObjectURL(blob);
var audioEl = new Audio();
audioEl.controls = true;
audioEl.src = newUrl;
document.getElementById('curTrackContainer').appendChild(audioEl);
 audioObj[i].sound.dispose();
audioObj[i].sound = new BABYLON.Sound(newName+i, newUrl, scene, null, { loop: false, autoplay: false });

The audio file plays okay from the audio element, but when I try to have babylon play it, I get this error:

BJS - [21:52:42]: Error while trying to play audio: Sampled15010375539220, TypeMismatchError

babylon.customRC.js (6025,13)

 

This method works fine in version 2.5 but breaks in 3.0.  Any help would be appreciated, if we know what has changed in that space.

Thanks,

Jeff

Link to comment
Share on other sites

Hello Jeff,

I don't remember supporting playing blob directly, I'm surprised it was working in the past. It supports:

- an ArrayBuffer or url to the sound to be played
- an array of urls to be played (to provide for instance .ogg and .mp3 and let the browser choose the format supported to be played)

For instance, this sample: http://playground.babylonjs.com/#E9CKPE is using an ArrayBuffer as an input. 

I can add support for blob: url but it should work by either passing an ArrayBuffer (you can easily transform your blob into an ArrayBuffer).

David

 

Link to comment
Share on other sites

I'll try it out.  so remember the app I previewed to you about a year ago, well I am still working on it and getting close.  The scenario is that when you are recording a story, you can also record an audio track for each page of your story.  The architectureI have in place right now isn't really great.  Basically I do this:

1. record voice track with get user media
2. pull the wave immediately out and set it to a "preview" audio element and pass the wav into a Babylonjs audio object
3. concert the wav to an mp3 in a separate thread
4. save the mp3 into an indexedDB (for later use) and then update the Babylonjs audio object with the mp3 file.

It's a bit of a mess right now, I convert it to mp3 so that it doesn't take up as much space, but it takes quite a while to convert it (several minutes sometimes).  I'm going to let you know how the sample works.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...