Logger displays errors even though code works.
My logger displays error codes concerning the .play() method copied directly from the Lens Studio API , even though the audio plays and works as it should in the preview. This is particularly frustrating because the lens works as it should but I am unable to publish it.
Any help would be appreciated.
Hi Gage,
That error is generated when the referenced Audio Component (in this case, script.audio) is undefined. Can you verify in the Inspector that the "Audio" property on your Script Component has been assigned to an Audio Component in your scene?
See the screenshot below for reference:
Let me know if you're still having trouble after connecting the Audio property, and I'll be happy to continue troubleshooting!
Best,
Peter
Thanks for your reply Peter,
The audio component is/was assigned, however as you can hopefully see from the gif above when I refresh the preview I still get the error message. If no audio component is assigned or I remove the line
//@input Component.AudioComponent audio
the lens preview freezes as it should.
As of now, the audio has been assigned and the lens plays as it should, yet I still get an error message that prevents me from uploading it.
thanks,
Hi Gage,
Sorry to hear your'e still running into difficulty. I have a few troubleshooting questions that will help me narrow down the cause of the error:
1) Does the Audio Component have its 'Audio Track' property set to an Audio Resource?
2) Is there possibly more than one instance of the script 'Script_2' in your scene? I ask because it looks like you're getting the error 3 times, but your script is set to trigger on Initialized, which should only happen once.
3) Have you tried creating a minimal, isolated audio playback test? For example, comment out line 17 in Script_2. Then create a new Script that is responsible only for playing of the audio. In other words, just:
Add that script to an entirely new Scene Object and see if you still get an error.
Let me know what you find after looking into those items, and we'll continue to troubleshoot.
Best,
Peter
Hi again Peter,
Thanks for your troubleshooting suggestions. Once you pointed out that there should only be one error message instead of three, I went back and searched through all of my scene objects and found that I had accidentally added an instance of script 2 to an object I wasn't using and found that the audio source was undefined (like you suggested earlier). After deleting the object the lens ran flawlessly and I was able to upload it. Thanks again for walking me through this, it really helped and I'll be sure to apply this when creating lenses in the future.
Best wishes,
gage.
I am aorking on a new lens you can seehere and facing some display issues if you have any solution please share here.