pythreejs icon indicating copy to clipboard operation
pythreejs copied to clipboard

Playing audio with pythreejs?

Open nthiery opened this issue 5 years ago • 2 comments

I have tried to reproduce the following threejs example in pythreejs, but with no success yet:

https://threejs.org/docs/#api/en/audio/Audio

import pythreejs
audioLoader = pythreejs.AudioLoader()
audioLoader.load("http://nicolas.thiery.name/sol.ogg")
AttributeError: 'AudioLoader' object has no attribute 'load'

Similarly, the Audio constructor takes no argument, etc.

Has anyone managed to play sound with pythreejs?

nthiery avatar Oct 25 '20 22:10 nthiery

The audio classes have not been specced out yet:

https://github.com/jupyter-widgets/pythreejs/blob/5857d541c0109ecacf64c2f515b1e446da6f1a30/js/scripts/three-class-config.js#L77-L91

For context: Is there a reason to prefer the pythreejs audio over IPython.display.Audio or ipywebrtc ?

vidartf avatar Nov 10 '20 13:11 vidartf

Hi Vidar! Thanks for the feedback.

Context: I am building a widget to display and analyze musical juggling patterns. To this end, I am toying out with threejs's animation capabilities (with AnimationClip ...) to animate the balls moving in the air. It's pretty fun to play with these capabilities!

Now, for the musical aspect, I need to play audio at certain times in the animation. This called for a pythreejs solution, but other option would certainly do.

If at all possible, I would like a solution that can be controlled purely from the Python side. For simplicity of deployment; because I am very slow at anything javascript; and also to empower the end users for whom Python is already a serious step.

The most versatile tool would be the ability to setup a callback to Python at certain times in the animation. Does pythreejs enable something like this?

Tips most welcome :-)

(sorry for the topic deviation in this issue)

nthiery avatar Nov 11 '20 09:11 nthiery