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
Fixes THREE.Audio.load is deprecated, closes #1472 #1629
Conversation
@@ -46,7 +47,14 @@ module.exports.Component = registerComponent('sound', { | |||
} | |||
|
|||
// All sound values set. Load in `src`. | |||
if (srcChanged) { sound.load(data.src); } | |||
if (srcChanged) { | |||
var audioLoader = this.audioLoader || new THREE.AudioLoader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we maybe initialize this in the init
method?
Yes, I added commit which initializes
Consider following scene using current aframe.js and that you have some tracks like <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,shrink-to-fit=no,user-scalable=no,minimal-ui">
<script src="https://raw.githubusercontent.com/aframevr/aframe/master/dist/aframe.js"></script>
</head>
<body>
<a-scene>
<a-entity sound="src: 1.mp3; autoplay: true" position="0 1 0"></a-entity>
</a-scene>
</body>
</html>
If you now use following aframe.js which has this PR applied <script src="https://raw.githubusercontent.com/mkungla/aframe/sound-AudioLoader-test/dist/aframe.js"></script> So removing file from TREE.Cache removes these errors and you can shuffle the tracks without any problems. It seems to be problem with TREE.js Cache which passes ArrayBuffer to AudioLoader.decodeAudioData while last expects instance of AudioBuffer. I have opend issue at TREE as well about that and keep eye on where it goes. For now I find that using |
@@ -9,7 +9,7 @@ var warn = debug('components:sound:warn'); | |||
*/ | |||
module.exports.Component = registerComponent('sound', { | |||
schema: { | |||
src: { default: '' }, | |||
src: { type: 'src' }, | |||
on: { default: 'click' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this default: ''
while you're here?
Yeah, can you update the examples and docs as well? Thanks! |
@ngokevin I'll go over all filed issues and collect some additional information before I file new issue about sound component what we talked about. Since this PR improves a lot compared to masters |
| Property | Description | Default Value | | ||
|----------|-----------------------------------------------------------------------|---------------| | ||
| autoplay | Whether to automatically play sound once set. | false | | ||
| on | An event for the entity to listen to before playing sound. | click | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default value for this is no longer click
srcChanged
I had to update audio src which caused these warnings.
THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.
Although this is not big issue I came across another problem that I could not play previous audio again.
so changing
src
on same entity back to audio which was already played causesThis happens since Three.
THREE.XHRLoader.load
returns for already played audio cache which is instance ofArrayBuffer
, but THREE.context.decodeAudioData expects instance ofAudioBuffer
Changes proposed:
Tree
to cache audio files