-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
THREE.AudioLoader load cached src #9323
Comments
Oh, can you provide a jsfiddle we can work with? |
@mrdoob One very RAW example // Set up the scene switching between tracks after 3 sec
// For this example I have 3 mp3 tracks in directory radio
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var audioListener = new THREE.AudioListener();
camera.add( audioListener );
var player = new THREE.Audio( audioListener );
player.autoplay = true;
scene.add( player );
var loader = new THREE.AudioLoader();
/**
* You will see errors in console when switch_track switches back to track 1
*
* The buffer passed to decodeAudioData contains an unknown content type.devel
* EncodingError: The given encoding is not supported.
*/
THREE.Cache.enabled = true;
/**
* THREE.Cache.enabled = false;
*
* Errors are gone and tracks switch
*/
var song_id = 1;
function switch_track(song_id) {
loader.load('radio/'+song_id+'.mp3', function ( audioBuffer ) {
player.setBuffer( audioBuffer );
});
}
setInterval(function(){
if(song_id > 3) song_id = 1;
switch_track(song_id);
song_id++;
},5000);
|
I get this error:
Which seems to be a limitation of the WebAudio API itself. |
@mrdoob your error comes from chrome I guess!? Does it switch all tracks first time and error occurs when |
In var cached = THREE.Cache.get( url );
if ( cached !== undefined ) {
if ( onLoad ) {
setTimeout( function () {
onLoad( cached );
}, 0 );
}
return cached;
} Is there any scenario where |
Yes.
No. It already fails when trying to play 2.mp3
Neither |
@mrdoob So in general seems indeed that this is not an a THREE issue, but limitation of WebAudio API itself to update buffer after it has been already been set. It's up to you either close this issue or is there something to investigate further. So as I understand changing audio |
I think |
Description of the problem
When I call to THREE.AudioLoader.load src on path which was already played on scene then I get errors
It seems that THREE.XHRLoader returns THREE.Cache
ArrayBuffer
and AudioLoader.decodeAudioData fails there.Three.js version
Browser
OS
The text was updated successfully, but these errors were encountered: