Playing a video from the "videoplayer" symbol with "Pointerdown" script


#1

I must be doing something wrong and have a question. I have an image with a “Pointerdown” script attached. I have a “videoplayer” symbol in the hierarchy and positioned on a plane that plays the video ( URL based - MP4) fine when set to “Auto Play”. I cannot figure out how to disable the “Auto Play” function and trigger the playback with the “Pointerdown” script so that when pressing the image the script is attached to, the video will play.

Any assistance will be much appreciated!


#2

@eprentice

Try this

Videoplayer.on(“ready”, () => {

Videoplayer.nodes.control.start();

});

Steve


#3

WOW thanks for the swift reply Steve!

I just tried and got the errors " Cannot find name “ready” and " Cannot find name “Videoplayer”

This is what I have attached to my Button.

parent.on(“pointerdown”, (e) => {
// Runs when pointerdown occurs on the parent node
// The argument e contains useful info about this event:
// https://docs.zap.works/studio/scripting/reference/object/events/pointerdown/

Videoplayer.on(“ready”, () => {

Videoplayer.nodes.control.start();
});

I sincerely appreciate your help.


#4

what is the name of your videoplayer in your hierarchy your trying to play?
You have to change the name to match. (Videoplayer_1)

Steve


#5

Sorry forgot to add.
Drag your Videoplayer in to you code above the (Parent.on )and add it’s local varible.

it should look like this.

const Videoplayer = symbol.nodes.Videoplayer;

parent.on(“pointerdown”, (e) => {
// Runs when pointerdown occurs on the parent node
// The argument e contains useful info about this event:
// https://docs.zap.works/studio/scripting/reference/object/events/pointerdown/

Videoplayer.on(“ready”, () => {

Videoplayer.nodes.control.start();
});


#6

Here are two images one with the screen and one showing the error message. Looks like we are getting close. Thanks Steve!


#7

Sorry, I posted just as I was leaving the office.
We missed this at the end of the code ---- }); -----

I made a quick file for you.

Steve

eprentice Help.zpp (583.5 KB)


#8

Excellent! Thanks so much Steve! That was the ticket. I really appreciate it!

A tip from my end… We have been using Reallusion IClone 7 to create some great 3D 360 VR Images with the new " one step" export feature they have. 3D Max can do it with a lot more steps if you ever need 3D environments for your projects.


#9

Hello Steve, I forgot to ask what additional code would be needed to pause the video if the same object is pressed again. Basically a toggle On and Off function. I am sure it has something to do with the " is playing" output of the video file to decide what the pointerdown function will do.

Thanks again for your help Steve.


#10

Try this…

const Videoplayer = symbol.nodes.Videoplayer;
var VideoPlaying;

Videoplayer.on(“video:playing”, () => {
VideoPlaying = true;
});

Videoplayer.on(“video:paused”, () => {
VideoPlaying = false;
});

Videoplayer.on(“video:finish”, () => {
VideoPlaying = false;
Videoplayer.nodes.control.restart();
Videoplayer.nodes.control.pause();
// Comment out the pause line if you don’t want the video to restat after it finishes
});

parent.on(“pointerdown”, (e) => {
// Runs when pointerdown occurs on the parent node
// The argument e contains useful info about this event:
// https://docs.zap.works/studio/scripting/reference/object/events/pointerdown/

Videoplayer.on("ready", () => {

 if(VideoPlaying === true){
   Videoplayer.nodes.control.pause() 
} else  {
   Videoplayer.nodes.control.start()	 
};
});

});

Steve


#11

Hmm getting the Name not found error message for VideolPlaying and Pause. If you can update the file and send if you have time that would be great Steve! Really appreciate all your help!


#12

eprentice Help with pause.zpp (583.7 KB)

I don’t know why the copy and paste isn’t work but here you go.

your welcome

Steve


#13

YOU DA MAN! YEP it works now! Maybe the copy and Paste from the site leaves some garbage ASCII code we cannot see! All i need now is the draggable 360 VR Image. Maybe that code in a zpp file will do the trick. I did not get any errors but did not know how to make it work.

Thanks Steve!


#14

I just remembered you did send me the 360 VR code in a ZPP file. Dooooooooooo! Thanks Steve. I just can’t seem to get it to work with a 360 VR Image. I see the reference to the “myvid” file in the code and get stuck there.
That is why there are no “errors” since you sent the ZPP file this go round.


#15

Hello Steve,

I saw another post with the same question. If it can be done one basic solution would be to have a 180 Degree button. The viewer can then look at the forward facing 180 Arc and then press the " 180 Button" to flip the view and see the rear facing 180 degree Arc. Then they would not have to turn in a complete circle to see the whole view. Of course if the ZPP file you sent works on images versus just video that would work well also.