Error if setting source in VideoPlayer

Hi there,
I have a question about the symbol VideoPlayer.
I use the code “symbol.nodes.[videoPlayer].nodes.show0.myvid.source([url])” to set the video source by script but it isn’t working: if I try to scan the zappar code it locks in an infinite loading. Why?

Hi @aron.tessari,

Please take a look at my response from the other forum post. This may give you some help when trying to understand how the Video Player symbol works! :slight_smile:

Thanks,
George

1 Like

@George
I read that and I appreciate it but I don’t understand why I cannot set the video URL from script (doing that freezes zappar).
I know I can do this by editing the property from the UI but I have to do it from js

Hi @aron.tessari,

Please try using this line of code if using the VideoPlayer subsymbol.

symbol.nodes.Videoplayer.nodes.show0.myvid.source(“URL”);

The application usually freezes indefinitely when there is a blank script or a function is trying to call something before it is instantiated.

Hope this helps!
George

@George Thanks for your answer.

Please try to do those steps:
1- create a new blank project
2- press ‘+’ in the symbol definitions and create a Video player symbol
3- put the Video player symbol inside the hierarchy
4- create a new blank script and write symbol.nodes.Videoplayer.nodes.show0.myvid.source("[url]");
5- now press the preview button and see the result: it isn’t going to work!

P.S.: ‘[url]’ is the video url. I can give it through private message if necessary.
P.P.S.: If I set the video url from the parameter “Video Url” under the properties tab it is going to work

Hi @aron.tessari,

You are very close, but a few issues arise with the steps you are taking.

Please try this -

1- create a new blank project
2- press ‘+’ in the symbol definitions and create a Video player symbol
3- put the Video player symbol inside the hierarchy
4- create a new blank script
5- create an event to tell the experience when to get the URL source - for example -

parent.on(“ready”, () =>{
//Add code here
};

6- write symbol.nodes.Videoplayer.nodes.show0.myvid.source("[url]"); into the event handler

In your example, it was creating a blank script node that was never called, in turn creating a never-ending loading screen.

Adding an event handler tells the script when the video URL should be loaded.

For the example given above, it will wait until the parent node in the Hierarchy is ready then run anything within that event.

Hope this helps.
George

Thanks, it works

1 Like